Using the content of a STRING from C

François Perrad francois.perrad at gadz.org
Fri Nov 13 08:56:49 UTC 2009


WMLScript is a bytecode translator (http://github.com/fperrad/wmlscript).
1) in PIR, read the content of a binary file, the result is in a STRING
2) in PMC WmlsBytecode, the method load() transform this STRING in a
complex PIR structure (Hash of Hash, ...)
2.1) the first step is to retrieve a C string, with Parrot_string_cstring()
2.2) after, a pointer walks on this C string (only reading, no writing)

My code has worked well in the past.
I don't known if it's a change of the C API, or a new bug in Parrot,
or a hidden bug in WmlsBytecode.pmc.
But now, I obtain a segfault :

Program received signal SIGSEGV, Segmentation fault.
0x0028c204 in _get_uint8 () at ./wmlsbytecode.pmc:70
70	    return _get_c();
(gdb) bt
#0  0x0028c204 in _get_uint8 () at ./wmlsbytecode.pmc:70
#1  0x0028c787 in _load_constant_pool (interp=0x8050040) at
./wmlsbytecode.pmc:194
#2  0x0028d344 in Parrot_WmlsBytecode_nci_load (interp=0x8050040,
pmc=0x80baa18) at ./wmlsbytecode.pmc:433
#3  0x004c9204 in Parrot_NCI_invoke (interp=0x8050040, pmc=0x80baa18,
next=0x810cf7c) at ./src/pmc/nci.pmc:338
#4  0x00305fd7 in Parrot_callmethodcc_p_sc (cur_opcode=0x810cf70,
interp=0x8050040) at src/ops/object.ops:74
#5  0x003e91cb in runops_slow_core (interp=0x8050040,
runcore=0x80dcea0, pc=0x810cf70) at src/runcore/cores.c:844
#6  0x003e7a1f in runops_int (interp=0x8050040, offset=0) at
src/runcore/main.c:546
#7  0x0039355a in runops (interp=0x8050040, offs=0) at src/call/ops.c:97
#8  0x0038b1b2 in Parrot_pcc_invoke_from_sig_object (interp=0x8050040,
sub_obj=0x80ba644, call_object=0x80ba66c) at src/call/pcc.c:296
#9  0x0038aba3 in Parrot_pcc_invoke_sub_from_c_args (interp=0x8050040,
sub_obj=0x80ba644, sig=0x59b1b6 "P->") at src/call/pcc.c:74
#10 0x0036e06e in Parrot_runcode (interp=0x8050040, argc=2,
argv=0xbffff468) at src/embed.c:828
#11 0x0056fdd3 in imcc_run_pbc (interp=0x8050040, obj_file=0,
output_file=0x0, argc=2, argv=0xbffff468) at compilers/imcc/main.c:793
#12 0x005709cf in imcc_run (interp=0x8050040, sourcefile=0xbffff5fb
"wmlsd.pir", argc=2, argv=0xbffff468) at compilers/imcc/main.c:1076
#13 0x080489a9 in main (argc=2, argv=0xbffff468) at src/main.c:60

Instructions with WMLScript :
    $ cpan WAP::Wmls
    $ cat hello.wmls
    extern function main()
    {
        Console.println("Hello World!");
    }
    $ wmlsc hello.wmls
    $ parrot wmlsd.pir hello.wmlsc


François


More information about the parrot-dev mailing list