Backport #5634

yield and binding

Added by Thomas Sawyer over 2 years ago. Updated over 1 year ago.

[ruby-core:41038]
Status:Closed
Priority:Normal
Assignee:Usaku NAKAMURA

Description

Per my recent question on ruby-core... "well there's your problem":

def x
binding
end
=> nil
b = x{|a|a+a}
=> #Binding:0x0000000103f1a0
b.eval('yield(2)')

(irb):2: [BUG] Segmentation fault
ruby 1.9.3dev (2011-09-23 revision 33323) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0026 p:0007 s:0091 b:0090 l:001ff8 d:000089 EVAL (irb):2
c:0025 p:---- s:0088 b:0088 l:000087 d:000087 FINISH
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC :eval
c:0023 p:0013 s:0082 b:0082 l:0009a8 d:000081 EVAL (irb):6
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:000a28 d:000057 BLOCK /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:273
c:0016 p:0011 s:0045 b:0045 l:000a28 d:000044 BLOCK /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:000a28 d:000a28 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:155
c:0007 p:0011 s:0019 b:0019 l:000658 d:000018 BLOCK /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0183 s:0011 b:0011 l:000658 d:000658 METHOD /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0039 s:0006 b:0006 l:0007a8 d:001e18 EVAL /home/trans/.rbenv/versions/1.9.3-rc1/bin/irb:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0007a8 d:0007a8 TOP

-- Ruby level backtrace information ----------------------------------------
/home/trans/.rbenv/versions/1.9.3-rc1/bin/irb:12:in <main>'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:69:in
start'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:69:in catch'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:70:in
block in start'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:155:in eval_input'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in
eachtoplevelstatement'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in catch'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in
block in each
toplevelstatement'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in loop'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in
block (2 levels) in eachtoplevelstatement'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:156:in block in eval_input'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:273:in
signal
status'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb:159:in block (2 levels) in eval_input'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/context.rb:254:in
evaluate'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/workspace.rb:80:in evaluate'
/home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/workspace.rb:80:in
eval'
(irb):6:in irb_binding'
(irb):6:in
eval'
(irb):2:in `x'

-- C level backtrace information -------------------------------------------
irb() [0x526f18]
irb() [0x56ecb8]
irb(rbbug+0xb3) [0x56ee53]
irb() [0x4b42b0]
/lib/libpthread.so.0(+0xf8f0) [0x7f8c9f5d38f0]
irb() [0x517a16]
irb() [0x51ba3b]
irb() [0x51c4da]
irb() [0x51ca86]
irb() [0x41ac06]
irb() [0x52072e]
irb() [0x5178d7]
irb() [0x51ba3b]
irb() [0x51c4da]
irb() [0x51ca86]
irb() [0x52072e]
irb() [0x5178d7]
irb() [0x51ba3b]
irb() [0x526259]
irb(rb
rescue2+0x15b) [0x417b9b]
irb() [0x5119c9]
irb() [0x52072e]
irb() [0x5178d7]
irb() [0x51ba3b]
irb() [0x51eb0e]
irb(rbcatchobj+0xbe) [0x51082e]
irb() [0x51161a]
irb() [0x52072e]
irb() [0x5178d7]
irb() [0x51ba3b]
irb() [0x51eb0e]
irb(rbcatchobj+0xbe) [0x51082e]
irb() [0x51161a]
irb() [0x52072e]
irb() [0x5178d7]
irb() [0x51ba3b]
irb(rbiseqevalmain+0x292) [0x51be72]
irb() [0x417f32]
irb(ruby
runnode+0x36) [0x419ff6]
irb() [0x4170d9]
/lib/libc.so.6(
libcstart_main+0xfd) [0x7f8c9e997c4d]
irb() [0x416fc9]

-- Other runtime information -----------------------------------------------

  • Loaded script: irb

  • Loaded features:

    0 enumerator.so
    1 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/enc/encdb.so
    2 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
    64-linux/enc/trans/transdb.so
    3 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/defaults.rb
    4 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/rbconfig.rb
    5 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/deprecate.rb
    6 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/exceptions.rb
    7 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/custom
    require.rb
    8 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems.rb
    9 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/psych.so
    10 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
    64-linux/stringio.so
    11 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/node.rb
    12 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/stream.rb
    13 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/document.rb
    14 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/sequence.rb
    15 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/scalar.rb
    16 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/mapping.rb
    17 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes/alias.rb
    18 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/nodes.rb
    19 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/streaming.rb
    20 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/visitor.rb
    21 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/strscan.so
    22 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/scalar
    scanner.rb
    23 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/toruby.rb
    24 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/emitter.rb
    25 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/yaml
    tree.rb
    26 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/json/rubyevents.rb
    27 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/json
    tree.rb
    28 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors/depthfirst.rb
    29 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/visitors.rb
    30 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/handler.rb
    31 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/tree
    builder.rb
    32 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/parser.rb
    33 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/omap.rb
    34 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/set.rb
    35 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/coder.rb
    36 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/coreext.rb
    37 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
    64-linux/datecore.so
    38 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/date/format.rb
    39 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/date.rb
    40 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/deprecated.rb
    41 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych/json.rb
    42 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/psych.rb
    43 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/yaml.rb
    44 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/coreext/rbconfig.rb
    45 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/xdg.rb
    46 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll/control.rb
    47 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/command.rb
    48 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll/original.rb
    49 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/coreext/file.rb
    50 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/library/requirements.rb
    51 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll/library/metadata.rb
    52 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/library/script.rb
    53 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll/library/version.rb
    54 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/library.rb
    55 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll/ruby.rb
    56 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/roll/kernel.rb
    57 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/siteruby/1.9.1/roll.rb
    58 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/site
    ruby/1.9.1/oll.rb
    59 ubygems.rb
    60 rubygems.rb
    61 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/ubygems.rb
    62 irb.rb
    63 e2mmap.rb
    64 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/e2mmap.rb
    65 irb/init.rb
    66 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/init.rb
    67 irb/context.rb
    68 irb/workspace.rb
    69 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/workspace.rb
    70 irb/inspector.rb
    71 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/inspector.rb
    72 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/context.rb
    73 irb/extend-command.rb
    74 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/extend-command.rb
    75 irb/ruby-lex.rb
    76 irb/slex.rb
    77 irb/notifier.rb
    78 irb/output-method.rb
    79 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/output-method.rb
    80 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/notifier.rb
    81 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/slex.rb
    82 irb/ruby-token.rb
    83 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-token.rb
    84 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/ruby-lex.rb
    85 irb/input-method.rb
    86 irb/srcencoding.rb
    87 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/src
    encoding.rb
    88 irb/magic-file.rb
    89 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/magic-file.rb
    90 readline.so
    91 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/readline.so
    92 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/input-method.rb
    93 irb/locale.rb
    94 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/locale.rb
    95 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb.rb
    96 rubygems/version.rb
    97 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/version.rb
    98 rubygems/requirement.rb
    99 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/requirement.rb
    100 rubygems/platform.rb
    101 rubygems/deprecate.rb
    102 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/platform.rb
    103 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/specification.rb
    104 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/path
    support.rb
    105 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/rubygems/dependency.rb
    106 ostruct.rb
    107 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/ostruct.rb
    108 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/wirble-0.1.3/lib/wirble.rb
    109 pp.rb
    110 prettyprint.rb
    111 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/prettyprint.rb
    112 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/pp.rb
    113 irb/completion.rb
    114 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/irb/completion.rb

  • Process memory map:

00400000-00616000 r-xp 00000000 08:01 5575135 /home/trans/.rbenv/versions/1.9.3-rc1/bin/ruby
00815000-00816000 r--p 00215000 08:01 5575135 /home/trans/.rbenv/versions/1.9.3-rc1/bin/ruby
00816000-00818000 rw-p 00216000 08:01 5575135 /home/trans/.rbenv/versions/1.9.3-rc1/bin/ruby
00818000-00834000 rw-p 00000000 00:00 0
00a47000-012f9000 rw-p 00000000 00:00 0 [heap]
7f8c9d264000-7f8c9d27a000 r-xp 00000000 08:01 18972791 /lib/libgccs.so.1
7f8c9d27a000-7f8c9d479000 ---p 00016000 08:01 18972791 /lib/libgcc
s.so.1
7f8c9d479000-7f8c9d47a000 r--p 00015000 08:01 18972791 /lib/libgccs.so.1
7f8c9d47a000-7f8c9d47b000 rw-p 00016000 08:01 18972791 /lib/libgcc
s.so.1
7f8c9d47b000-7f8c9d4b9000 r-xp 00000000 08:01 18972805 /lib/libncurses.so.5.7
7f8c9d4b9000-7f8c9d6b9000 ---p 0003e000 08:01 18972805 /lib/libncurses.so.5.7
7f8c9d6b9000-7f8c9d6bd000 r--p 0003e000 08:01 18972805 /lib/libncurses.so.5.7
7f8c9d6bd000-7f8c9d6be000 rw-p 00042000 08:01 18972805 /lib/libncurses.so.5.7
7f8c9d6be000-7f8c9d6f7000 r-xp 00000000 08:01 18972819 /lib/libreadline.so.6.1
7f8c9d6f7000-7f8c9d8f6000 ---p 00039000 08:01 18972819 /lib/libreadline.so.6.1
7f8c9d8f6000-7f8c9d8f8000 r--p 00038000 08:01 18972819 /lib/libreadline.so.6.1
7f8c9d8f8000-7f8c9d8fe000 rw-p 0003a000 08:01 18972819 /lib/libreadline.so.6.1
7f8c9d8fe000-7f8c9d8ff000 rw-p 00000000 00:00 0
7f8c9d8ff000-7f8c9d905000 r-xp 00000000 08:01 8702444 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/readline.so
7f8c9d905000-7f8c9db04000 ---p 00006000 08:01 8702444 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/readline.so
7f8c9db04000-7f8c9db05000 r--p 00005000 08:01 8702444 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/readline.so
7f8c9db05000-7f8c9db06000 rw-p 00006000 08:01 8702444 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/readline.so
7f8c9db06000-7f8c9db3a000 r-xp 00000000 08:01 8702448 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/datecore.so
7f8c9db3a000-7f8c9dd39000 ---p 00034000 08:01 8702448 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/datecore.so
7f8c9dd39000-7f8c9dd3a000 r--p 00033000 08:01 8702448 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/datecore.so
7f8c9dd3a000-7f8c9dd3b000 rw-p 00034000 08:01 8702448 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/datecore.so
7f8c9dd3b000-7f8c9dd3c000 rw-p 00000000 00:00 0
7f8c9dd3c000-7f8c9dd41000 r-xp 00000000 08:01 8702451 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/strscan.so
7f8c9dd41000-7f8c9df41000 ---p 00005000 08:01 8702451 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/strscan.so
7f8c9df41000-7f8c9df42000 r--p 00005000 08:01 8702451 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/strscan.so
7f8c9df42000-7f8c9df43000 rw-p 00006000 08:01 8702451 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/strscan.so
7f8c9df43000-7f8c9df4a000 r-xp 00000000 08:01 8702446 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/stringio.so
7f8c9df4a000-7f8c9e149000 ---p 00007000 08:01 8702446 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/stringio.so
7f8c9e149000-7f8c9e14a000 r--p 00006000 08:01 8702446 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/stringio.so
7f8c9e14a000-7f8c9e14b000 rw-p 00007000 08:01 8702446 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/stringio.so
7f8c9e14b000-7f8c9e16a000 r-xp 00000000 08:01 39535253 /home/trans/.rbenv/versions/1.9.3-rc1/lib/libyaml-0.so.2.0.2
7f8c9e16a000-7f8c9e369000 ---p 0001f000 08:01 39535253 /home/trans/.rbenv/versions/1.9.3-rc1/lib/libyaml-0.so.2.0.2
7f8c9e369000-7f8c9e36a000 r--p 0001e000 08:01 39535253 /home/trans/.rbenv/versions/1.9.3-rc1/lib/libyaml-0.so.2.0.2
7f8c9e36a000-7f8c9e36b000 rw-p 0001f000 08:01 39535253 /home/trans/.rbenv/versions/1.9.3-rc1/lib/libyaml-0.so.2.0.2
7f8c9e36b000-7f8c9e370000 r-xp 00000000 08:01 8702452 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/psych.so
7f8c9e370000-7f8c9e570000 ---p 00005000 08:01 8702452 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/psych.so
7f8c9e570000-7f8c9e571000 r--p 00005000 08:01 8702452 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/psych.so
7f8c9e571000-7f8c9e572000 rw-p 00006000 08:01 8702452 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/psych.so
7f8c9e572000-7f8c9e574000 r-xp 00000000 08:01 9421126 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/enc/trans/transdb.so
7f8c9e574000-7f8c9e774000 ---p 00002000 08:01 9421126 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/enc/trans/transdb.so
7f8c9e774000-7f8c9e775000 r--p 00002000 08:01 9421126 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/enc/trans/transdb.so
7f8c9e775000-7f8c9e776000 rw-p 00003000 08:01 9421126 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/enc/trans/transdb.so
7f8c9e776000-7f8c9e778000 r-xp 00000000 08:01 9421099 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/enc/encdb.so
7f8c9e778000-7f8c9e977000 ---p 00002000 08:01 9421099 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/enc/encdb.so
7f8c9e977000-7f8c9e978000 r--p 00001000 08:01 9421099 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x8664-linux/enc/encdb.so
7f8c9e978000-7f8c9e979000 rw-p 00002000 08:01 9421099 /home/trans/.rbenv/versions/1.9.3-rc1/lib/ruby/1.9.1/x86
64-linux/enc/encdb.so
7f8c9e979000-7f8c9eaf3000 r-xp 00000000 08:01 18972789 /lib/libc-2.11.1.so
7f8c9eaf3000-7f8c9ecf2000 ---p 0017a000 08:01 18972789 /lib/libc-2.11.1.so
7f8c9ecf2000-7f8c9ecf6000 r--p 00179000 08:01 18972789 /lib/libc-2.11.1.so
7f8c9ecf6000-7f8c9ecf7000 rw-p 0017d000 08:01 18972789 /lib/libc-2.11.1.so
7f8c9ecf7000-7f8c9ecfc000 rw-p 00000000 00:00 0
7f8c9ecfc000-7f8c9ed7e000 r-xp 00000000 08:01 18972854 /lib/libm-2.11.1.so
7f8c9ed7e000-7f8c9ef7d000 ---p 00082000 08:01 18972854 /lib/libm-2.11.1.so
7f8c9ef7d000-7f8c9ef7e000 r--p 00081000 08:01 18972854 /lib/libm-2.11.1.so
7f8c9ef7e000-7f8c9ef7f000 rw-p 00082000 08:01 18972854 /lib/libm-2.11.1.so
7f8c9ef7f000-7f8c9ef88000 r-xp 00000000 08:01 18972806 /lib/libcrypt-2.11.1.so
7f8c9ef88000-7f8c9f188000 ---p 00009000 08:01 18972806 /lib/libcrypt-2.11.1.so
7f8c9f188000-7f8c9f189000 r--p 00009000 08:01 18972806 /lib/libcrypt-2.11.1.so
7f8c9f189000-7f8c9f18a000 rw-p 0000a000 08:01 18972806 /lib/libcrypt-2.11.1.so
7f8c9f18a000-7f8c9f1b8000 rw-p 00000000 00:00 0
7f8c9f1b8000-7f8c9f1ba000 r-xp 00000000 08:01 18972823 /lib/libdl-2.11.1.so
7f8c9f1ba000-7f8c9f3ba000 ---p 00002000 08:01 18972823 /lib/libdl-2.11.1.so
7f8c9f3ba000-7f8c9f3bb000 r--p 00002000 08:01 18972823 /lib/libdl-2.11.1.so
7f8c9f3bb000-7f8c9f3bc000 rw-p 00003000 08:01 18972823 /lib/libdl-2.11.1.so
7f8c9f3bc000-7f8c9f3c3000 r-xp 00000000 08:01 18973094 /lib/librt-2.11.1.so
7f8c9f3c3000-7f8c9f5c2000 ---p 00007000 08:01 18973094 /lib/librt-2.11.1.so
7f8c9f5c2000-7f8c9f5c3000 r--p 00006000 08:01 18973094 /lib/librt-2.11.1.so
7f8c9f5c3000-7f8c9f5c4000 rw-p 00007000 08:01 18973094 /lib/librt-2.11.1.so
7f8c9f5c4000-7f8c9f5dc000 r-xp 00000000 08:01 18973092 /lib/libpthread-2.11.1.so
7f8c9f5dc000-7f8c9f7db000 ---p 00018000 08:01 18973092 /lib/libpthread-2.11.1.so
7f8c9f7db000-7f8c9f7dc000 r--p 00017000 08:01 18973092 /lib/libpthread-2.11.1.so
7f8c9f7dc000-7f8c9f7dd000 rw-p 00018000 08:01 18973092 /lib/libpthread-2.11.1.so
7f8c9f7dd000-7f8c9f7e1000 rw-p 00000000 00:00 0
7f8c9f7e1000-7f8c9f801000 r-xp 00000000 08:01 18972752 /lib/ld-2.11.1.so
7f8c9f894000-7f8c9f995000 rw-p 00000000 00:00 0
7f8c9f995000-7f8c9f9d4000 r--p 00000000 08:01 10846233 /usr/lib/locale/enUS.utf8/LCCTYPE
7f8c9f9d4000-7f8c9f9d9000 rw-p 00000000 00:00 0
7f8c9f9f1000-7f8c9f9f3000 rw-p 00000000 00:00 0
7f8c9f9f3000-7f8c9f9f4000 ---p 00000000 00:00 0
7f8c9f9f4000-7f8c9f9f7000 rw-p 00000000 00:00 0
7f8c9f9f7000-7f8c9f9fe000 r--s 00000000 08:01 23150643 /usr/lib/gconv/gconv-modules.cache
7f8c9f9fe000-7f8c9fa00000 rw-p 00000000 00:00 0
7f8c9fa00000-7f8c9fa01000 r--p 0001f000 08:01 18972752 /lib/ld-2.11.1.so
7f8c9fa01000-7f8c9fa02000 rw-p 00020000 08:01 18972752 /lib/ld-2.11.1.so
7f8c9fa02000-7f8c9fa03000 rw-p 00000000 00:00 0
7fffaa009000-7fffaa01f000 rw-p 00000000 00:00 0 [stack]
7fffaa095000-7fffaa096000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted

fix-yield-from-eval-segfault.patch Magnifier (336 Bytes) Charlie Somerville, 11/27/2012 06:47 PM

env_block.patch Magnifier (2.01 KB) Koichi Sasada, 11/27/2012 09:56 PM


Related issues

Duplicated by ruby-trunk - Bug #5912: Interpreter crashes when trying to invoke implicit block ... Closed 01/20/2012

Associated revisions

Revision 38314
Added by Usaku NAKAMURA over 1 year ago

[Backport #5634]

  • vm.c (rbvmmakeenvobject): make Proc object if Env is possible
    to point block. [ruby-trunk - Bug #5634]

  • vm.c (rbvmmake_proc): No need to make Proc object here.

  • bootstraptest/test_proc.rb: add tests.

History

#1 Updated by Nobuyoshi Nakada over 2 years ago

I could reproduce it with 2.0.0dev on darwin11, but only with irb.
Still can't simplify it without irb.

#2 Updated by Nobuyoshi Nakada over 2 years ago

=begin
Probably, this would be the simplest code.

$ ./miniruby -e 'def x;binding;end' -e 'b = eval(%[x{}])' -e 'b.eval("yield")'
-e:1: [BUG] Segmentation fault
ruby 2.0.0dev (2011-11-15 trunk 33755) [x86_64-darwin11.0]
=end

#3 Updated by Nobuyoshi Nakada over 2 years ago

  • Category set to core
  • Target version set to 2.0.0

#4 Updated by Heesob Park over 2 years ago

This segmentation fault occurs on the line #949 of vminsnhelper.c(vminvokeblock)
if (BUILTIN
TYPE(iseq) != T_NODE) {

The variable iseq is NULL in this case.

#5 Updated by Koichi Sasada about 2 years ago

  • Assignee set to Koichi Sasada

#6 Updated by Shyouhei Urabe about 2 years ago

  • Status changed from Open to Assigned

#7 Updated by Koichi Sasada almost 2 years ago

  • Priority changed from Normal to High

#8 Updated by Koichi Sasada over 1 year ago

  • Status changed from Assigned to Feedback

Not reproduced at trunk.
Someone fixed it?

#9 Updated by Charlie Somerville over 1 year ago

Reproducible at trunk with this code:

def x
  binding
end

eval("x { }").eval "yield"

Curiously, the segfault only occurs if the call to 'x' happens inside eval.

#10 Updated by Koichi Sasada over 1 year ago

Thank you!

Priority -> High.

#11 Updated by Charlie Somerville over 1 year ago

The presence of a block arg seems to prevent the segfault.

This works as expected:

def f(&bk); binding; end
eval("f { puts 'hi' }").eval("yield")

This segfaults:

def f(); binding; end
eval("f { puts 'hi' }").eval("yield")

#12 Updated by Koichi Sasada over 1 year ago

The following code is also cause same bug.

def x
binding
end

def m
x{p 1}
end

eval('yield', m)

#13 Updated by Charlie Somerville over 1 year ago

I think I may have a solution, just making sure my patch doesn't break anything else first...

#14 Updated by Charlie Somerville over 1 year ago

The attached patch seems to fix it for me. I ran 'make test-all' and only one (unrelated) test failed so I don't think I've broken anything.

#15 Updated by Koichi Sasada over 1 year ago

(2012/11/27 18:47), charliesome (Charlie Somerville) wrote:

The attached patch seems to fix it for me. I ran 'make test-all' and only one (unrelated) test failed so I don't think I've broken anything.

Unfortunately, your patch will not solve the issue.

Could you try it?

###

def x
binding
end

def m1
x{p 1}
end

def m2
x{p 2}
end

bm1 = m1
b
m2 = m2
eval('yield', m1)

--
// SASADA Koichi at atdot dot net

#16 Updated by Koichi Sasada over 1 year ago

(2012/11/27 19:11), SASADA Koichi wrote:

eval('yield', m1)

Ah, "eval('yield', b_m1)" I want to write.

--
// SASADA Koichi at atdot dot net

#17 Updated by Koichi Sasada over 1 year ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37898.
Thomas, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • vm.c (rbvmmakeenvobject): make Proc object if Env is possible to point block. [ruby-trunk - Bug #5634]
  • vm.c (rbvmmake_proc): No need to make Proc object here.
  • bootstraptest/test_proc.rb: add tests.

#18 Updated by Koichi Sasada over 1 year ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport93
  • Category deleted (core)
  • Status changed from Closed to Open
  • Assignee changed from Koichi Sasada to Usaku NAKAMURA
  • Priority changed from High to Normal
  • Target version deleted (2.0.0)

The following patch is for 1.9.3.
I don't run test-all with 1.9.3. Please check it.


Index: bootstraptest/test_proc.rb

--- bootstraptest/testproc.rb (revision 37898)
+++ bootstraptest/test
proc.rb (working copy)
@@ -456,3 +456,27 @@ assert_equal 'ok', %q{
end
}

+assertequal 'ok', %q{
+ def x
+ binding
+ end
+ b = x{|a| a }
+ b.eval('yield("ok")')
+}, '[Bug #5634]'
+
+assert
equal 'ok', %q{
+ def x
+ binding
+ end
+ eval("x { 'ok' }").eval "yield"
+}, '[Bug #5634]'
+
+assert_equal 'ok', %q{
+ def x
+ binding
+ end
+ def m
+ x{ 'ok' }
+ end
+ eval('yield', m)
+}, '[Bug #5634]'

Index: vm.c

--- vm.c (revision 37898)
+++ vm.c (working copy)
@@ -467,14 +467,28 @@ vmcollectlocalvariablesinheap(rbth
}
}

+static VALUE vmmakeprocfromblock(rbthreadt *th, rbblockt *block);
+
VALUE
rbvmmakeenvobject(rbthreadt * th, rbcontrolframet *cfp)
{
VALUE envval;
+ VALUE *lfp;
+ rb
block_t *blockptr;

 if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_FINISH) {
/* for method_missing */
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
  • } +
  • lfp = cfp->lfp;
  • blockptr = GCGUARDEDPTR_REF(lfp[0]); +
  • if (blockptr && !(lfp[0] & 0x02)) {
  • VALUE blockprocval = vmmakeprocfromblock(th, blockptr);
  • rbproct *p;
  • GetProcPtr(blockprocval, p);
  • lfp[0] = GCGUARDEDPTR(&p->block);
    }

    envval = vmmakeenv_each(th, cfp, cfp->dfp, cfp->lfp);

#19 Updated by Koichi Sasada over 1 year ago

I fix previous patch (attached fixed one).

#20 Updated by Usaku NAKAMURA over 1 year ago

  • Status changed from Open to Closed

This issue was solved with changeset r38314.
Thomas, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


[Backport #5634]

  • vm.c (rbvmmakeenvobject): make Proc object if Env is possible
    to point block. [ruby-trunk - Bug #5634]

  • vm.c (rbvmmake_proc): No need to make Proc object here.

  • bootstraptest/test_proc.rb: add tests.

Also available in: Atom PDF