lsegal/ripper18 — Issue #7: Ripper::SexpBuilder#parse produces invalid objects in presence of method calls
Author: stcrocco
Created: 2011-10-31 13:17:11+00:00
State: open

In ruby 1.8.7-p352, using Ripper::SexpBuilder#parse with code containing method calls with the usual dot notation produces an array with elements whose inspect method causes ruby to crash. For example, the following code

```ruby
require 'ripper'
Ripper::SexpBuilder.new("a.b").parse.inspect
```
causes the crash. Calling inspect recursively on each element of the array indicates that the problem arises on the ```:"."``` node. Using to_s rather than inspect, raises the following exception:
```
ArgumentError: NULL pointer given
```
Ripper from ruby 1.9 works correctly. Running ruby through gdb produces the following backtrace (on gentoo linux 64 bit compiled with gcc 4.5.3):

```

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff77d2571 in __strlen_sse2 () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff77d2571 in __strlen_sse2 () from /lib64/libc.so.6
#1 0x00007ffff7b40c5a in sym_inspect (sym=) at object.c:1167
#2 0x00007ffff7b140ce in rb_call0 (klass=140737353860000, recv=11790, id=3145, oid=, argc=0, argv=0x0, body=0x7ffff7fbc210, flags=0) at eval.c:5938
#3 0x00007ffff7b142ad in rb_call (klass=140737353860000, recv=11790, mid=3145, argc=0, argv=0x0, scope=1, self=) at eval.c:6186
#4 0x00007ffff7b14968 in vafuncall (recv=, mid=, n=, ar=) at eval.c:6263
#5 0x00007ffff7b14c05 in rb_funcall (recv=, mid=, n=) at eval.c:6280
#6 0x00007ffff7b420e6 in rb_inspect (obj=) at object.c:334
#7 0x00007ffff7af53b6 in inspect_ary (ary=140737353666400) at array.c:1568
#8 0x00007ffff7b0f372 in rb_ensure (b_proc=0x7ffff7af4210 , data1=140737488333456, e_proc=0x7ffff7af8040 , data2=140737353666400) at eval.c:5581
#9 0x00007ffff7af8c82 in rb_protect_inspect (func=0x7ffff7af5360 , obj=140737353666400, arg=0) at array.c:1544
#10 0x00007ffff7b140ce in rb_call0 (klass=140737353800760, recv=140737353666400, id=3145, oid=, argc=0, argv=0x0, body=0x7ffff7fada30, flags=0) at eval.c:5938
#11 0x00007ffff7b142ad in rb_call (klass=140737353800760, recv=140737353666400, mid=3145, argc=0, argv=0x0, scope=1, self=) at eval.c:6186
#12 0x00007ffff7b14968 in vafuncall (recv=, mid=, n=, ar=) at eval.c:6263
#13 0x00007ffff7b14c05 in rb_funcall (recv=, mid=, n=) at eval.c:6280
#14 0x00007ffff7b420e6 in rb_inspect (obj=) at object.c:334
#15 0x00007ffff7af53b6 in inspect_ary (ary=140737353666120) at array.c:1568
#16 0x00007ffff7b0f372 in rb_ensure (b_proc=0x7ffff7af4210 , data1=140737488336416, e_proc=0x7ffff7af8040 , data2=140737353666120) at eval.c:5581
#17 0x00007ffff7af8c82 in rb_protect_inspect (func=0x7ffff7af5360 , obj=140737353666120, arg=0) at array.c:1544
#18 0x00007ffff7b140ce in rb_call0 (klass=140737353800760, recv=140737353666120, id=3145, oid=, argc=0, argv=0x0, body=0x7ffff7fada30, flags=0) at eval.c:5938
#19 0x00007ffff7b142ad in rb_call (klass=140737353800760, recv=140737353666120, mid=3145, argc=0, argv=0x0, scope=1, self=) at eval.c:6186
#20 0x00007ffff7b14968 in vafuncall (recv=, mid=, n=, ar=) at eval.c:6263
#21 0x00007ffff7b14c05 in rb_funcall (recv=, mid=, n=) at eval.c:6280
#22 0x00007ffff7b420e6 in rb_inspect (obj=) at object.c:334
#23 0x00007ffff7af53b6 in inspect_ary (ary=140737353666040) at array.c:1568
#24 0x00007ffff7b0f372 in rb_ensure (b_proc=0x7ffff7af4210 , data1=140737488339376, e_proc=0x7ffff7af8040 , data2=140737353666040) at eval.c:5581
#25 0x00007ffff7af8c82 in rb_protect_inspect (func=0x7ffff7af5360 , obj=140737353666040, arg=0) at array.c:1544
#26 0x00007ffff7b140ce in rb_call0 (klass=140737353800760, recv=140737353666040, id=3145, oid=, argc=0, argv=0x0, body=0x7ffff7fada30, flags=0) at eval.c:5938
#27 0x00007ffff7b142ad in rb_call (klass=140737353800760, recv=140737353666040, mid=3145, argc=0, argv=0x0, scope=0, self=) at eval.c:6186
#28 0x00007ffff7b19668 in rb_eval (self=140737353855640, n=0x7ffff7f35170) at eval.c:3516
#29 0x00007ffff7b1fdbb in ruby_exec_internal () at eval.c:1664
#30 0x00007ffff7b1fe05 in ruby_exec () at eval.c:1684
#31 0x00007ffff7b22555 in ruby_run () at eval.c:1694
#32 0x000000000040095c in main (argc=1, argv=, envp=) at main.c:48
```