[MacRuby-devel] [MacRuby] #814: SegFault running CGI script from command line
MacRuby
ruby-noreply at macosforge.org
Tue Jul 27 11:38:44 PDT 2010
#814: SegFault running CGI script from command line
-------------------------------+--------------------------------------------
Reporter: pwilson@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone: MacRuby 0.7
Component: MacRuby | Keywords:
-------------------------------+--------------------------------------------
Old description:
> With latest MacRuby nightly (July 27), the following code causes a seg
> fault if run directly from the command line:
>
> {{{
> require 'cgi'
> c = CGI.new
> }}}
>
> It works OK when run through the web server. When ruby 1.9 runs this
> from the command line it asks for data from stdin to serve as query
> parameters.
>
> Under MacRuby I get this crash:
>
> {{{
> (offline mode: enter name=value pairs on standard input)
> Segmentation fault
> }}}
>
> and this stack trace:
>
> {{{
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: 13 at address: 0x0000000000000000
> 0x000000010005818a in rb_f_open ()
> (gdb) bt
> #0 0x000000010005818a in rb_f_open ()
> #1 0x000000010005b7cd in rb_io_gets ()
> #2 0x0000000100140a39 in rb_vm_dispatch ()
> #3 0x0000000102f004d0 in ?? ()
> #4 0x0000000102f0c32c in ?? ()
> #5 0x0000000100140996 in rb_vm_dispatch ()
> #6 0x0000000102f004d0 in ?? ()
> #7 0x0000000102f0d319 in ?? ()
> #8 0x0000000100140996 in rb_vm_dispatch ()
> #9 0x0000000102f004d0 in ?? ()
> #10 0x0000000102f0e43f in ?? ()
> #11 0x000000010014097b in rb_vm_dispatch ()
> #12 0x000000010006e342 in rb_class_new_instance_imp ()
> #13 0x0000000100140a39 in rb_vm_dispatch ()
> #14 0x0000000102f004d0 in ?? ()
> #15 0x0000000102f000bd in ?? ()
> #16 0x000000010014d708 in rb_vm_run ()
> #17 0x000000010003fef0 in ruby_run_node ()
> #18 0x0000000100000d28 in main ()
> }}}
New description:
With latest MacRuby nightly (July 27), the following code causes a seg
fault if run directly from the command line:
{{{
#!ruby
require 'cgi'
c = CGI.new
}}}
It works OK when run through the web server. When ruby 1.9 runs this from
the command line it asks for data from stdin to serve as query parameters.
Under MacRuby I get this crash:
{{{
(offline mode: enter name=value pairs on standard input)
Segmentation fault
}}}
and this stack trace:
{{{
(gdb) bt
#0 0x00007fff832c5120 in objc_msgSend ()
#1 0x0000000100043ff1 in rb_io_read_internal (io_struct=0x101166520,
buffer=0x7fff5fbfb5cf "", len=1) at io.c:981
#2 0x000000010004900f in rb_io_gets_m (io=<value temporarily unavailable,
due to optimizations>, sel=<value temporarily unavailable, due to
optimizations>, argc=<value temporarily unavailable, due to
optimizations>, argv=<value temporarily unavailable, due to
optimizations>) at io.c:1423
#3 0x000000010004b20c in rb_io_readlines [inlined] () at
/Users/naixn/Documents/Projets/MacRuby/io.c:1549
#4 0x000000010004b20c in argf_readlines (argf=<value temporarily
unavailable, due to optimizations>, sel=0x101112ac0, argc=0, argv=0x0) at
io.c:3422
#5 0x00000001001303c9 in rb_vm_dispatch (_vm=0x100f1e4a0,
cache=0x100e78cc0, top=8590007072, self=8590007072, klass=0x2000ca420,
sel=0x101112ac0, block=0x0, opt=1 '\001', argc=0, argv=0x0) at
dispatcher.cpp:435
#6 0x000000010355a4d0 in ?? ()
#7 0x000000010356632c in ?? ()
#8 0x0000000100130326 in rb_vm_dispatch (_vm=0x100f1e4a0,
cache=0x100e513c0, top=8590007072, self=8590007072, klass=0x2000ca420,
sel=0x105244590, block=0x0, opt=1 '\001', argc=<value temporarily
unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:159
#9 0x000000010355a4d0 in ?? ()
#10 0x0000000103567319 in ?? ()
#11 0x0000000100130326 in rb_vm_dispatch (_vm=0x100f1e4a0,
cache=0x100e6d8c0, top=8590007072, self=8590007072, klass=0x2000ca420,
sel=0x10526ce00, block=0x0, opt=2 '\002', argc=<value temporarily
unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:159
#12 0x000000010355a4d0 in ?? ()
#13 0x000000010356843f in ?? ()
#14 0x000000010013030b in rb_vm_dispatch (_vm=0x100f1e4a0,
cache=0x100e6bac0, top=0, self=8590007072, klass=0x200217ae0,
sel=0x7fff87e4d6b8, block=0x0, opt=2 '\002', argc=<value temporarily
unavailable, due to optimizations>, argv=0x7fff5fbfe060) at
dispatcher.cpp:161
#15 0x000000010005dd32 in rb_class_new_instance_imp (klass=<value
temporarily unavailable, due to optimizations>, sel=<value temporarily
unavailable, due to optimizations>, argc=0, argv=0x0) at vm.h:594
#16 0x00000001001303c9 in rb_vm_dispatch (_vm=0x100f1e4a0,
cache=0x100e66fc0, top=8590070304, self=8592128736, klass=0x200217aa0,
sel=0x7fff87e4d700, block=0x0, opt=0 '\0', argc=0, argv=0x0) at
dispatcher.cpp:435
#17 0x000000010355a4d0 in ?? ()
#18 0x000000010355a0bd in ?? ()
#19 0x000000010013d108 in rb_vm_run (fname=<value temporarily unavailable,
due to optimizations>, node=0x2000ceb40, binding=<value temporarily
unavailable, due to optimizations>, inside_eval=false) at vm.cpp:3787
#20 0x000000010002f8b0 in ruby_run_node (n=0x2000ceb40) at eval.c:211
#21 0x0000000100000cf8 in main (argc=2, argv=0x100f1de20, envp=<value
temporarily unavailable, due to optimizations>) at main.cpp:40
(gdb) call rb_symbolicate(0x000000010356632c)
addr 0x10356632c start 0x103566120 selector read_from_cmdline location
/Library/Frameworks/MacRuby.framework/Versions/0.7/usr/lib/ruby/1.9.2/cgi/core.rb:542
(gdb) fr 1
#1 0x0000000100043ff1 in rb_io_read_internal (io_struct=0x101166520,
buffer=0x7fff5fbfb5cf "", len=1) at io.c:981
981 if (io_struct->buf == NULL || CFDataGetLength(io_struct->buf)
== 0) {
Current language: auto; currently c
(gdb) p io_struct
$1 = (rb_io_t *) 0x101166520
(gdb) po io_struct
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000013
0x00007fff832c52b6 in objc_msgSend_fixup ()
error on line 266 of "/SourceCache/gdb/gdb-1502/src/gdb/macosx/i386
-macosx-nat-exec.c" in function "store_inferior_registers": (os/kern)
invalid argument (0x4)
}}}
--
Comment(by martinlagardette@…):
Modified the stack trace for a more correct interpretation. The crash
occurs when `rb_io_read_internal()` calls `CFDataGetLength` on
`io_struct->buf`. GDB also whines when trying to `po io_struct`. The IO
being read is `ARGF.current_file`, is there a change the corresponding IO
struct is not correctly initialized?
--
Ticket URL: <http://www.macruby.org/trac/ticket/814#comment:1>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list