ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults
@ 2020-12-28 21:23 shatrov
  2021-01-05  1:34 ` [ruby-core:101919] " ko1
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: shatrov @ 2020-12-28 21:23 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been reported by kirs (Kir Shatrov).

----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489

* Author: kirs (Kir Shatrov)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attach the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:101919] [Ruby master Bug#17489] Ractor segfaults
  2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
@ 2021-01-05  1:34 ` ko1
  2021-01-05 21:25 ` [ruby-core:101940] " yura.des
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ko1 @ 2021-01-05  1:34 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been updated by ko1 (Koichi Sasada).

Assignee set to ko1 (Koichi Sasada)
Status changed from Open to Assigned

Thank you. I can confirm the reproducing. This issue is maybe from the lack of synchronization for the constant table.

----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489#change-89765

* Author: kirs (Kir Shatrov)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attached the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:101940] [Ruby master Bug#17489] Ractor segfaults
  2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
  2021-01-05  1:34 ` [ruby-core:101919] " ko1
@ 2021-01-05 21:25 ` yura.des
  2022-03-25 11:29 ` [ruby-core:108066] " wanabe (_ wanabe)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: yura.des @ 2021-01-05 21:25 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been updated by inversion (Yura Babak).


During my Ractors tests I had segfaults many times and easy to reproduce (in my environment). 
The same code crashes on Linux and Windows10 (sometimes with other numbers of iterations or workers).
More Ractors seems to increase the segfault rate.
And if I add `GC.disable` — no crash.

So I was looking for a place where to add a report with my code samples.
This issue looks like a good place for this.

**Test cases:**
crash_reused_sha2.rb
https://gist.github.com/Inversion-des/fcc7dbb2d9a77a7dba540c29077e5ebf 
(90% crash, if I uncomment GC.disable — no crash)

crash_encrypt_big_data_often.rb
https://gist.github.com/Inversion-des/a9dbde4eacfa859e5bd7cc8fd8a8049f
(50% crash, again uncomment GC.disable — no crash)

Win10_crash_report.txt
https://gist.github.com/Inversion-des/c79ea00407c579b83ebbe00541e20c45

If it doesn't crash for you — try to increase number of iterations and data size.

My environment:
**Linux CentOS 7.9 (VPS)**
4-core CPU 2.6GHz
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
**Windows 10**
2-core CPU 3.6GHz
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]



----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489#change-89787

* Author: kirs (Kir Shatrov)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attached the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:108066] [Ruby master Bug#17489] Ractor segfaults
  2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
  2021-01-05  1:34 ` [ruby-core:101919] " ko1
  2021-01-05 21:25 ` [ruby-core:101940] " yura.des
@ 2022-03-25 11:29 ` wanabe (_ wanabe)
  2022-03-26  9:50 ` [ruby-core:108083] " kirs (Kir Shatrov)
  2022-03-26 20:36 ` [ruby-core:108086] " wanabe (_ wanabe)
  4 siblings, 0 replies; 6+ messages in thread
From: wanabe (_ wanabe) @ 2022-03-25 11:29 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been updated by wanabe (_ wanabe).


It seems be a autoload on non-main Ractor problem [Bug #18120].
This operation is prohibited after https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/397a509b6d0d1470df8c290d7c4adef78f1532ee and does not result in a BUG thereafter.

----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489#change-97027

* Author: kirs (Kir Shatrov)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attached the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:108083] [Ruby master Bug#17489] Ractor segfaults
  2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
                   ` (2 preceding siblings ...)
  2022-03-25 11:29 ` [ruby-core:108066] " wanabe (_ wanabe)
@ 2022-03-26  9:50 ` kirs (Kir Shatrov)
  2022-03-26 20:36 ` [ruby-core:108086] " wanabe (_ wanabe)
  4 siblings, 0 replies; 6+ messages in thread
From: kirs (Kir Shatrov) @ 2022-03-26  9:50 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been updated by kirs (Kir Shatrov).


wanabe (_ wanabe) wrote in #note-6:
> It seems be a autoload on non-main Ractor problem [Bug #18120].
> This operation is prohibited after https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/397a509b6d0d1470df8c290d7c4adef78f1532ee and does not result in a BUG thereafter.

That's great news!

I wish I knew how to close this ticket. Not sure I have permissions to do that...?

----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489#change-97043

* Author: kirs (Kir Shatrov)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attached the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:108086] [Ruby master Bug#17489] Ractor segfaults
  2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
                   ` (3 preceding siblings ...)
  2022-03-26  9:50 ` [ruby-core:108083] " kirs (Kir Shatrov)
@ 2022-03-26 20:36 ` wanabe (_ wanabe)
  4 siblings, 0 replies; 6+ messages in thread
From: wanabe (_ wanabe) @ 2022-03-26 20:36 UTC (permalink / raw)
  To: ruby-core

Issue #17489 has been updated by wanabe (_ wanabe).

Status changed from Assigned to Closed

kirs (Kir Shatrov) wrote in #note-8:
> 
> I wish I knew how to close this ticket. Not sure I have permissions to do that...?

OK, I'll close it.

----------------------------------------
Bug #17489: Ractor segfaults
https://bugs.ruby-lang.org/issues/17489#change-97048

* Author: kirs (Kir Shatrov)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
I was able to boil it down to this script:

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem "sinatra", "~> 2.1"
end

require 'sinatra'

class App < Sinatra::Base
  get '/' do
    200
  end
end

module Sinatra
  class Base
    class << self
      # patch it to avoid hitting other unsafe things
      def setup_default_middleware(builder)
        builder.use Rack::NullLogger
      end
    end
  end
end

workers = 2.times.map do
  Ractor.new { App.new }
end

Ractor.select(*workers)
```

Even though the code doesn't make a lot of sense and Sinatra has other stuff that's not compatible with Ractor, I would not expect user-level Ruby code to segfault.


I have attached the crash report and stderr output.

---Files--------------------------------
segfault.dump (44.8 KB)
ruby_2020-12-29-002108_Kirs-MacBook-Pro-2.crash (27.9 KB)


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-26 20:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 21:23 [ruby-core:101797] [Ruby master Bug#17489] Ractor segfaults shatrov
2021-01-05  1:34 ` [ruby-core:101919] " ko1
2021-01-05 21:25 ` [ruby-core:101940] " yura.des
2022-03-25 11:29 ` [ruby-core:108066] " wanabe (_ wanabe)
2022-03-26  9:50 ` [ruby-core:108083] " kirs (Kir Shatrov)
2022-03-26 20:36 ` [ruby-core:108086] " wanabe (_ wanabe)

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).