#1345: Assertion fails when invoke an eval() within CGI.new ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Assertion occurs when is invoked an eval at following point. * https://github.com/MacRuby/MacRuby/blob/master/lib/cgi/html.rb#L881 * https://github.com/MacRuby/MacRuby/blob/master/lib/cgi/html.rb#L930 * https://github.com/MacRuby/MacRuby/blob/master/lib/cgi/html.rb#L981 * https://github.com/MacRuby/MacRuby/blob/master/lib/cgi/html.rb#L1015 Test Script: {{{ #!ruby require 'cgi' @environ = { 'REQUEST_METHOD' => 'GET', } ENV.update(@environ) cgi = CGI.new('html3') cgi = CGI.new('html4') cgi = CGI.new('html4Tr') cgi = CGI.new('html4Fr') }}} Result: {{{ $ DYLD_LIBRARY_PATH=. ./macruby -I./lib ~/tmp/ttt.rb Assertion failed: (len >= 0), function str_replace_with_uchars, file string.c, line 327. zsh: abort DYLD_LIBRARY_PATH=. ./macruby -I./lib ~/tmp/ttt.rb }}} BackTrace: {{{ Program received signal SIGABRT, Aborted. 0x00007fff83d0f0b6 in __kill () (gdb) bt #0 0x00007fff83d0f0b6 in __kill () #1 0x00007fff83daf9f6 in abort () #2 0x00007fff83d9c9bc in __assert_rtn () #3 0x00000001000b7845 in str_replace_with_uchars (self=0x2000218c0, chars=0xfffffffdfff1ab5d, len=-22431) at string.c:327 #4 0x00000001000c7269 in rb_unicode_str_new (ptr=0xfffffffdfff1ab5d, len=18446744073709529185) at string.c:6263 #5 0x0000000100085f3a in lex_getline [inlined] () at /Users/watson/src /macruby-master/parse.y:5071 #6 0x0000000100085f3a in ruby_yyparse (parser=<value temporarily unavailable, due to optimizations>) at parse.y:5213 #7 0x000000010009059a in yycompile0 (arg=<value temporarily unavailable, due to optimizations>, tracing=<value temporarily unavailable, due to optimizations>) at parse.y:5000 #8 0x0000000100090b75 in rb_parser_compile_string (vparser=<value temporarily unavailable, due to optimizations>, f=0x100992c3c "(eval)", s=8592144096, line=1) at parse.y:5033 #9 0x0000000100154d77 in rb_vm_eval_string (self=8590852352, klass=0, src=8590812672, binding=0x0, file=0x100992c3c "(eval)", line=1, should_push_outer=false) at vm.cpp:4245 #10 0x00000001000f32d9 in eval_string_with_should_push_outer (self=8590852352, klass=0, src=8590812672, scope=4, file=0x100992c3c "(eval)", line=1, should_push_outer=false) at vm_eval.c:299 #11 0x00000001000f33a8 in eval_string (self=8590852352, klass=0, src=8590812672, scope=4, file=0x100992c3c "(eval)", line=1) at vm_eval.c:320 #12 0x00000001000f3772 in rb_f_eval (self=8590852352, sel=0x100e271a0, argc=1, argv=0x7fff5fbfb750) at vm_eval.c:441 #13 0x000000010013b264 in rb_vm_dispatch (_vm=0x100e231d0, cache=0x100d7f560, top=8590852352, self=8590852352, klass=0x2000fbaa0, sel=0x100e271a0, block=0x0, opt=2 '\002', argc=1, argv=0x7fff5fbfb750) at dispatcher.cpp:448 #14 0x0000000103a00c54 in ?? () #15 0x0000000103a14e45 in ?? () #16 0x000000010013b7c4 in rb_vm_dispatch (_vm=0x100e231d0, cache=0x100d90d60, top=8590852352, self=8590852352, klass=0x2000fbaa0, sel=0x103e97ca0, block=0x0, opt=2 '\002', argc=<value temporarily unavailable, due to optimizations>, argv=0x0) at dispatcher.cpp:159 #17 0x0000000103a00c54 in ?? () #18 0x0000000103a0ecf0 in ?? () #19 0x000000010013b7a9 in rb_vm_dispatch (_vm=0x100e231d0, cache=0x100d97b30, top=0, self=8590852352, klass=0x2000dfea0, sel=0x7fff82ffe23e, block=0x0, opt=2 '\002', argc=<value temporarily unavailable, due to optimizations>, argv=0x7fff5fbfdd10) at dispatcher.cpp:161 #20 0x000000010006260a in rb_class_new_instance0 [inlined] () at /Users/watson/src/macruby-master/object.c:653 #21 0x000000010006260a in rb_class_new_instance_imp (klass=<value temporarily unavailable, due to optimizations>, sel=<value temporarily unavailable, due to optimizations>, argc=1, argv=0x7fff5fbfdd10) at object.c:2021 #22 0x000000010013b264 in rb_vm_dispatch (_vm=0x100e231d0, cache=0x100d93840, top=8590062368, self=8590851744, klass=0x2000bfec0, sel=0x100e22360, block=0x0, opt=0 '\0', argc=1, argv=0x7fff5fbfdd10) at dispatcher.cpp:448 #23 0x0000000103a00c54 in ?? () #24 0x0000000103a001c0 in ?? () #25 0x0000000100154306 in rb_vm_run (fname=0x2000a7480 "/Users/watson/tmp/ttt.rb", node=0x2000252a0, binding=<value temporarily unavailable, due to optimizations>, inside_eval=<value temporarily unavailable, due to optimizations>) at vm.cpp:4115 #26 0x0000000100030de0 in ruby_run_node (n=0x2000252a0) at eval.c:211 #27 0x0000000100000cf8 in main (argc=3, argv=0x100e1c040, envp=<value temporarily unavailable, due to optimizations>) at main.cpp:40 (gdb) }}} When rb_unicode_str_new() was invoked, it seems that broken length was passed. -- Ticket URL: <http://www.macruby.org/trac/ticket/1345> MacRuby <http://macruby.org/>