Project

General

Profile

Bug #9905

Fiber does not work on AIX

Added by ReiOdaira (Rei Odaira) about 5 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.2.0dev (2014-06-02 trunk 45270) [powerpc-aix7.1.0.0]
[ruby-core:62945]

Description

test/ruby/test_fiber.rb fails on AIX.

[ 2/23] TestFiber#test_argument/ss/home/rayod/Dev/Contribution/ruby-trunk-blue1/test/ruby/test_fiber.rb:19: [BUG] machine_stack_cache size is not canonicalized
ruby 2.2.0dev (2014-06-02 trunk 45270) [powerpc-aix7.1.0.0]

Here is what happens for this test:

  1. A fiber is created by setting context->uc_stack.ss_size to a certain value and calling makecontext().
  2. While the fiber is switched with other fibers by swapcontext(), context->uc_stack.ss_size is changed to a very large value by AIX.
  3. When the fiber finishes, its stack pointer and size are cached in machine_stack_cache[].
  4. When a new fiber is created, a specified stack size is different from the cached stack size, so the error is thrown.

I feel AIX's behavior is strange, but I also suppose in general, context->uc_stack.ss_size is not guaranteed to be preserved after makecontext() or swapcontext(). (Please correct me if I am wrong.)

Rather than disabling FIBER_USE_NATIVE for AIX, I propose saving the original stack pointer and size not in ucontext_t but in new dedicated fields in rb_fiber_t, as you can find in the attached patch. With this patch, test/ruby/test_fiber.rb results in no errors on AIX. This did not cause any error on Linux, either, for test or test-all.


Files

sp_and_size_for_fiber.patch (1.9 KB) sp_and_size_for_fiber.patch ReiOdaira (Rei Odaira), 06/05/2014 09:18 AM

Associated revisions

Revision d86cba89
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 46373: [Backport #9905]

    * cont.c (rb_fiber_struct): keep context.uc_stack.ss_sp and context.uc_stack.ss_size
      for later use. Patch by Rei Odaira. [ruby-core:62945] [Bug #9905]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@54273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54273
Added by usa (Usaku NAKAMURA) over 3 years ago

merge revision(s) 46373: [Backport #9905]

* cont.c (rb_fiber_struct): keep context.uc_stack.ss_sp and context.uc_stack.ss_size
  for later use. Patch by Rei Odaira. [ruby-core:62945] [Bug #9905]

History

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Description updated (diff)
  • Category set to platform/aix
  • Status changed from Open to Assigned
  • Assignee set to kanemoto (Yutaka Kanemoto)
  • Target version set to 2.2.0

Seems fine.

Updated by ReiOdaira (Rei Odaira) over 3 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED

Could you back-port this to 2.1 as well? Thanks.

Updated by naruse (Yui NARUSE) over 3 years ago

  • Status changed from Assigned to Closed

Change status as Closed to enqueue backport.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED to 2.0.0: UNKNOWN, 2.1: DONE

ruby_2_1 r54273 merged revision(s) 46373.

Also available in: Atom PDF