ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: alanwucanada@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90372] [Ruby trunk Bug#15250] Concurrent fibers segfault when thread caching is disabled
Date: Fri, 07 Dec 2018 16:53:28 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-75482.20181207165327.44670966b6f305d9@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15250.20181024130534@ruby-lang.org

Issue #15250 has been updated by alanwu (Alan Wu).


Sounds like a duplicate of #14561. It should be fixed on trunk already.

----------------------------------------
Bug #15250: Concurrent fibers segfault when thread caching is disabled
https://bugs.ruby-lang.org/issues/15250#change-75482

* Author: qyliss (Alyssa Ross)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-10-19) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~ ruby
500.times do
  Array.new(200) { |n|
    Thread.new {
      Fiber.new {
        readable = open(__FILE__)
        Fiber.yield readable.read(1)
      }.resume
    }
  }.each(&:join)
end
~~~

Getting the segfault doesn’t require nearly that many iterations or threads, I just made sure to do it a lot so I could reproduce it consistently. I’ve seen it fail with as few as 20 threads.

The IO isn’t necessary either. The Fiber just needs to have some work to do. I got it to break once by just yielding “hello world”. The IO is more consistent, though.

I came across this bug in the wild when using the fastimage gem in a few threads (from middleman), which uses a Fiber to wrap IO operations.

I’ve been able to reproduce on macOS 10.13, and SmartOS 2017Q4 (Solaris). I have not been able to reproduce on Linux.

As best I can tell, the crash was introduced by r60440. It is present in Ruby 2.5.x when compiled with the default configuration. It is not present in 2.4.x. It’s also present in trunk, but only if USE_THREAD_CACHE is disabled. (Or at least, I can’t reproduce it with thread caching enabled.)



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2018-12-07 16:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15250.20181024130534@ruby-lang.org>
2018-10-24 13:05 ` [ruby-core:89548] [Ruby trunk Bug#15250] Concurrent fibers segfault when thread caching is disabled hi
2018-12-07 16:53 ` alanwucanada [this message]
2018-12-10 17:13 ` [ruby-core:90406] " hi
2019-03-12 23:40 ` [ruby-core:91801] " nagachika00

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-75482.20181207165327.44670966b6f305d9@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).