Issue #2258 has been updated by Suraj Kurapati.


Hi,

By adding a watchpoint on the filename, I found that it
was being free()d by rb_newobj_from_heap() (not directly
but via garbage_collect()) before allocating space for a
few lines read from the standard "date.rb" file (see below).

How strange!  Why does the GC feel pressured to free
the filename (which is a VALUE inside Ruby's stack space)?
Is there not enough heap space for it to allocate a new object?

These are the questions I will investigate next.
Feel free to give me a hint if you know the answer.

Thanks for your consideration.

(gdb) bt
#0  0xb7e65b21 in _int_free () from /lib/libc.so.6
#1  0xb7e68d4d in free () from /lib/libc.so.6
#2  0x08070f4e in vm_xfree (objspace=0x86114f0, ptr=0x86af158) at gc.c:730
#3  0x080710a5 in ruby_xfree (x=0x86af158) at gc.c:778
#4  0x080fc031 in rb_str_free (str=140736600) at string.c:772
#5  0x0807315e in obj_free (objspace=0x86114f0, obj=140736600) at gc.c:2000
#6  0x08072c34 in gc_sweep (objspace=0x86114f0) at gc.c:1876
#7  0x080737c0 in garbage_collect (objspace=0x86114f0) at gc.c:2204
#8  0x08071662 in rb_newobj_from_heap (objspace=0x86114f0) at gc.c:1011
#9  0x0807171b in rb_newobj () at gc.c:1094
#10 0x080fab39 in str_alloc (klass=140776360) at string.c:378
#11 0x080fabd6 in str_new (klass=140776360, ptr=0x86bab89 "    new_by_frags(elem, sg)\n  end\n\n  # Create a new DateTime object by parsing from a String,\n  # without specifying the format.\n  #\n  # +str+ is a String holding a date-time representation.\n  # +comp+"..., len=27) at string.c:397
#12 0x080fad61 in rb_str_new (ptr=0x86bab89 "    new_by_frags(elem, sg)\n  end\n\n  # Create a new DateTime object by parsing from a String,\n  # without specifying the format.\n  #\n  # +str+ is a String holding a date-time representation.\n  # +comp+"..., len=27) at string.c:417
#13 0x0807e083 in rb_io_getline_fast (fptr=0x86af2e8, enc=0x8644898) at io.c:2254
#14 0x0807e4fc in rb_io_getline_1 (rs=140755540, limit=-1, io=140736380) at io.c:2347
#15 0x0807e884 in rb_io_gets (io=140736380) at io.c:2436
#16 0x080ac71f in lex_io_gets (parser=0x86af230, io=140736380) at parse.y:5140
#17 0x080ac534 in lex_getline (parser=0x86af230) at parse.y:5072
#18 0x080ac8b5 in parser_nextc (parser=0x86af230) at parse.y:5221
#19 0x080afa65 in parser_yylex (parser=0x86af230) at parse.y:6453
#20 0x080b2a78 in yylex (lval=0x8601df4, p=0x86af230) at parse.y:7658
#21 0x080a2b1e in ruby_yyparse (parser=0x86af230) at parse.c:4733
#22 0x080ac24f in yycompile0 (arg=141226544, tracing=0) at parse.y:5009
#23 0x08156741 in ruby_suppress_tracing (func=0x80ac14c <yycompile0>, arg=141226544, always=1) at thread.c:4031
#24 0x080ac3a1 in yycompile (parser=0x86af230, f=0x86af158 "@\364j\be/sun/app/ruby/lib/ruby/1.9.1/date.rb", line=1) at parse.y:5035
#25 0x080ac7c6 in rb_parser_compile_file (vparser=140736400, f=0x86af158 "@\364j\be/sun/app/ruby/lib/ruby/1.9.1/date.rb", file=140736380, start=1) at parse.y:5164
#26 0x080f0e73 in load_file_internal (arg=140517824) at ruby.c:1582
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2258

----------------------------------------
http://redmine.ruby-lang.org