[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66222] [ruby-trunk - Bug #10428] Segmentation fault when modifying local variables of binding obtained from the result of Method#to_proc
From:
nobu@...
Date:
2014-11-12 09:23:15 UTC
List:
ruby-core #66222
Issue #10428 has been updated by Nobuyoshi Nakada.
Related to Bug #10432: wrong receiver of Binding from Method added
----------------------------------------
Bug #10428: Segmentation fault when modifying local variables of binding obtained from the result of Method#to_proc
https://bugs.ruby-lang.org/issues/10428#change-49912
* Author: Stanislav Gatev
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: 2.1.3p242 (2014-09-19 revision 47630)
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
The issue pops up when Method#to_proc is called, then the binding of that proc is obtained, and one tries to modify (get/set) the local variables in that binding.
Lets examine the code below.
```
class Foo
def bar
end
end
instance = Foo.new
method_proc = instance.method(:bar).to_proc
b = method_proc.binding
b.local_variable_set(:value, [1, 2, 3])
```
Running this code with `ruby 2.1.3p242 (2014-09-19 revision 47630)` on OS X results in Segmentation Fault:
```
bug.rb:10: [BUG] Segmentation fault at 0x00000000000070
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin14.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
c:0003 p:---- s:0012 e:000011 CFUNC :local_variable_set
c:0002 p:0053 s:0007 E:001780 EVAL bug.rb:10 [FINISH]
c:0001 p:0000 s:0002 E:001838 TOP [FINISH]
bug.rb:10:in `<main>'
bug.rb:10:in `local_variable_set'
-- C level backtrace information -------------------------------------------
0 libruby.2.1.0.dylib 0x0000000104099ff0 rb_vm_bugreport + 144
1 libruby.2.1.0.dylib 0x0000000103f4b251 report_bug + 305
2 libruby.2.1.0.dylib 0x0000000103f4b114 rb_bug + 180
3 libruby.2.1.0.dylib 0x000000010401c04c sigsegv + 156
4 libsystem_platform.dylib 0x00007fff8fb45f1a _sigtramp + 26
5 libruby.2.1.0.dylib 0x0000000103f5cfe0 bind_local_variable_set + 128
6 ??? 0x0000000000003170 0x0 + 12656
-- Other runtime information -----------------------------------------------
* Loaded script: bug.rb
* Loaded features:
0 enumerator.so
1 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/x86_64-darwin14.0/enc/encdb.bundle
2 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/x86_64-darwin14.0/enc/trans/transdb.bundle
3 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/x86_64-darwin14.0/rbconfig.rb
4 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/compatibility.rb
5 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/defaults.rb
6 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/deprecate.rb
7 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/errors.rb
8 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/version.rb
9 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/requirement.rb
10 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/platform.rb
11 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/basic_specification.rb
12 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/stub_specification.rb
13 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb
14 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/exceptions.rb
15 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
16 thread.rb
17 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/x86_64-darwin14.0/thread.bundle
18 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/monitor.rb
19 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb
20 /Users/s2gatev/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html
```
I noticed the same issue is present in the trunk. The functionality for getting Proc out of Method seems to be discussed and accepted. I noticed that it was introduced with [f331b55](https://github.com/ruby/ruby/commit/f331b5584edbf106ab85f4663ddbe55031176b3a).
Perhaps I am not getting something right but I'm wondering if you have considered this scenario when introducing the change?
I have suggested a fix on [GitHub](https://github.com/ruby/ruby/pull/746). I'm not sure if it is correct and would like to receive some feedback on it.
--
https://bugs.ruby-lang.org/