Ticket #814 (closed defect: fixed)
SegFault running CGI script from command line
| Reported by: | pwilson@… | Owned by: | lsansonetti@… |
|---|---|---|---|
| Priority: | blocker | Milestone: | MacRuby 0.7 |
| Component: | MacRuby | Keywords: | |
| Cc: |
Description (last modified by martinlagardette@…) (diff)
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:
(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)
Change History
Note: See
TracTickets for help on using
tickets.

