Leopold Toetsch wrote:

Matthias . Hoelzl @ ifi . lmu . de <[EMAIL PROTECTED]> wrote:


Parrot segfaults when executing the appended function.



It's hard to tell, what's the problem. A debugger backtrace with information about the relevant variables could help.

And: if the code runs with "parrot -G" then it's likely a GC bug. If the
segfault is happening earlier, when you run with --gc-debug and/or -t,
the it's very likely a GC bug.


The code runs fine with the "-G" flag and also with the "--gc-debug" flag. It segfaults before finishing the first test when run with the -t flag.
I have appended a backtrace with information about the relevant variables. The backtrace seems to support your conclusion that the segfault happens during garbage collection.


Best is of course to extract a small piece of code that exposes the
error :)


Sorry. I tried for some time to generate a small test case. But as soon as I remove significant parts of the program, the segfault disappears... :-|

Matthias
Current directory is /usr/local/parrot-0.1.1/bin/
GNU gdb Red Hat Linux (6.0post-0.20040223.19rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library 
"/lib/tls/libthread_db.so.1".

(gdb) cd /home/tc/prog/parrot/girls/tests 
Working directory /home/tc/prog/parrot/girls/tests.
(gdb) run test-bootstrap.pbc
Starting program: /usr/local/parrot-0.1.1/bin/parrot test-bootstrap.pbc
[Thread debugging using libthread_db enabled]
[New Thread -151099072 (LWP 5119)]
[New Thread -159786064 (LWP 5122)]
[New Thread -170275920 (LWP 5123)]
Starting main
Testing binding...done
Generating global get...done
Generating global get...done
Generating global set...done
Generating global set...done
Generating scope_entry...done
Generating scope_exit...done
Generating lexical get...done
Generating lexical get...done
Generating lexical set...done
Generating lexical set...done
Generating invocation...done
Generating label...done
Generating label...done
Generating label...done
Generating label...done
Generating function header...done
Generating function header...done
Generating function header...done
Generating temporary name...done
Generating temporary name...done
Generating temporary name...done
Generating temporary name...done
Generating temporary name...done
Compiling literal list...done

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -151099072 (LWP 5119)]
0x080e4169 in pobject_lives (interpreter=0x940a008, obj=0x11) at src/dod.c:198
(gdb) print *interpreter
$1 = {int_reg = {registers = {1, 0, 0, 1, 0 <repeats 28 times>}}, num_reg = {registers 
= {
      0 <repeats 32 times>}}, string_reg = {registers = {0x95df60c, 0x0, 0x0, 0x0, 
0x0, 0x9546744, 
      0x954678c, 0x95472a8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9546744, 
      0x0 <repeats 15 times>}}, pmc_reg = {registers = {0x943d800, 0x943d848, 
0x943e580, 0x9448338, 
      0x9448338, 0x943d9b0, 0x95a52f0, 0x9448338, 0x9448338, 0x9448338, 0x9448338, 
0x9448338, 
      0x9448338, 0x9448338, 0x9448338, 0x9448338, 0x943d9b0, 0x943d848, 0x943d800, 
0x943d998, 
      0x9448338 <repeats 12 times>}}, ctx = {int_reg_stack = 0x95ad0b0, num_reg_stack 
= 0x95b9d70, 
    string_reg_stack = 0x95ad290, pmc_reg_stack = 0x95ad230, pad_stack = 0x95c0170, 
    user_stack = 0x95c0140, control_stack = 0x95c0110, intstack = 0x95c01a8, warns = 
0, errors = 1, 
    current_class_offset = 0, recursion_depth = 3, runloop_level = 1, current_sub = 
0x943d860, 
    current_cont = 0x943d848, current_object = 0x943e580}, globals = 0x942ced8, 
  arena_base = 0x940a798, class_hash = 0x95a9d60, piodata = 0x940a380, op_lib = 
0x82c7e40, 
  op_count = 1570, op_info_table = 0x82b3f20, op_func_table = 0x82b2680, 
evc_func_table = 0x95e9d28, 
  save_func_table = 0x82b2680, n_libs = 0, all_op_libs = 0x0, flags = NO_FLAGS, 
  run_core = PARROT_SLOW_CORE, profile = 0x0, cur_pc = 0xf538be10, resume_flag = 0, 
resume_offset = 0, 
  code = 0x95c3dc8, prederef = {code = 0x0, branches = 0x0, n_branches = 0, 
n_allocated = 0}, 
  jit_info = 0x0, imc_info = 0x95c3d88, current_line = 0, current_file = 0x95966e8, 
  current_package = 0x9597fcc, pdb = 0x0, lo_var_ptr = 0xfeed4dc0, parent_interpreter 
= 0x0, 
  world_inited = 1, iglobals = 0x95a96a0, DOD_registry = 0x0, binop_mmd_funcs = 
0x942d9b8, 
  n_binop_mmd_funcs = 50, caches = 0x95acfe0, const_cstring_table = 0x942d5f0, 
task_queue = 0x95c3d30, 
  sleeping = 0, exceptions = 0x95e9c68, exc_free_list = 0x95f2e40, exception_list = 
0x95c05b8, 
  thread_data = 0x0, recursion_limit = 1000}
(gdb) print *obj
Cannot access memory at address 0x11
(gdb) up
#1  0x080a09da in mark_1_seg (interpreter=0x940a008, cs=0x95c3f68) at 
src/packfile.c:360
(gdb) print *cs
$2 = {base = {pf = 0x95c3dc8, dir = 0x95c3dc8, type = 4, 
    name = 0x95c3fb8 "BYTECODE_test-bootstrap.pir", op_count = 51352, file_offset = 
44, itype = 0, 
    id = 0, size = 51345, data = 0xf535a0c0}, prederef = {code = 0x0, branches = 0x0, 
n_branches = 0, 
    n_allocated = 0}, jit_info = 0x0, prev = 0x960e430, debugs = 0x0, consts = 
0x95c4030, 
  fixups = 0x95c3fd8}
(gdb) print *ct
$3 = {base = {pf = 0x95c3dc8, dir = 0x95c3dc8, type = 3, 
    name = 0x95c4068 "CONSTANT_test-bootstrap.pir", op_count = 6612, file_offset = 
60800, itype = 0, 
    id = 0, size = 0, data = 0x0}, const_count = 730, constants = 0x95d62d8, code = 
0x95c3f68}
(gdb) print *ft
$4 = {base = {pf = 0x95c3dc8, dir = 0x95c3dc8, type = 2, name = 0x95c4010 
"FIXUP_test-bootstrap.pir", 
    op_count = 9404, file_offset = 51396, itype = 0, id = 0, size = 0, data = 0x0}, 
  fixup_count = 1405, fixups = 0x95c4088, code = 0x95c3f68}
(gdb) print *sub_pmc
$5 = {obj = {u = {_b = {_bufstart = 0x95a58f0, _buflen = 157183576}, _ptrs = 
{_struct_val = 0x95a58f0, 
        _pmc_val = 0x95e6e58}, _i = {_int_val = 156915952, _int_val2 = 157183576}, 
      _num_val = 1.5100122518759912e-263, _string_val = 0x95a58f0}, flags = 524288, 
    _pobj_version = 0}, vtable = 0x9434f18, pmc_ext = 0x0}
(gdb) print *((parrot_sub_t)(sub_pmc->obj.u._ptrs._pmc_val))
$6 = {seg = 0x73, address = 0x95df06c, end = 0x0, name = 0x11, 
  packed = 0x73 <Address 0x73 out of bounds>, use_reg_offs = 157151304, pad_stack = 
0x0}
(gdb) print *(ct->constants)
$7 = (struct PackFile_Constant *) 0x95d6e48
(gdb) print ci
$8 = 607
(gdb) print *(ct->constants[ci])
$9 = {type = 112, u = {integer = 156918952, number = 7.7528263364611566e-316, string = 
0x95a64a8, 
    key = 0x95a64a8}}
(gdb) print *(ct->constants[ci]->u.key)
$10 = {obj = {u = {_b = {_bufstart = 0x95a58f0, _buflen = 157183576}, _ptrs = {
        _struct_val = 0x95a58f0, _pmc_val = 0x95e6e58}, _i = {_int_val = 156915952, 
        _int_val2 = 157183576}, _num_val = 1.5100122518759912e-263, _string_val = 
0x95a58f0}, 
    flags = 524288, _pobj_version = 0}, vtable = 0x9434f18, pmc_ext = 0x0}
(gdb) up
#2  0x080a0a34 in find_code_iter (seg=0x95c3f68, user_data=0x940a008) at 
src/packfile.c:375
(gdb) print *(struct PackFile_ByteCode *)seg
$11 = {base = {pf = 0x95c3dc8, dir = 0x95c3dc8, type = 4, 
    name = 0x95c3fb8 "BYTECODE_test-bootstrap.pir", op_count = 51352, file_offset = 
44, itype = 0, 
    id = 0, size = 51345, data = 0xf535a0c0}, prederef = {code = 0x0, branches = 0x0, 
n_branches = 0, 
    n_allocated = 0}, jit_info = 0x0, prev = 0x960e430, debugs = 0x0, consts = 
0x95c4030, 
  fixups = 0x95c3fd8}
(gdb) print interp
$12 = 0x940a008
(gdb) up
#3  0x080a0ef8 in PackFile_map_segments (dir=0x95c3dc8, callback=0x80a09f0 
<find_code_iter>, 
    user_data=0x940a008) at src/packfile.c:687
(gdb) print *dir
$13 = {base = {pf = 0x95c3dc8, dir = 0x0, type = 0, name = 0x95c3f28 "DIRECTORY", 
op_count = 67404, 
    file_offset = 32, itype = 0, id = 0, size = 0, data = 0x0}, num_segments = 4, 
segments = 0x95f4750}
(gdb) print *callback
$14 = {INTVAL (struct PackFile_Segment *, void *)} 0x80a09f0 <find_code_iter>
(gdb) print ret
$15 = 0
(gdb) up
#4  0x080a0a7f in mark_const_subs (interpreter=0x940a008) at src/packfile.c:399
(gdb) print *self
$16 = {directory = {base = {pf = 0x95c3dc8, dir = 0x0, type = 0, name = 0x95c3f28 
"DIRECTORY", 
      op_count = 67404, file_offset = 32, itype = 0, id = 0, size = 0, data = 0x0}, 
num_segments = 4, 
    segments = 0x95f4750}, dirp = 0x95c3ef0, src = 0xf535a000, size = 269648, 
is_mmap_ped = 1, 
  header = 0x95c3ec8, PackFuncs = {{new_seg = 0x80a1b70 <directory_new>, 
      destroy = 0x80a20c0 <directory_destroy>, packed_size = 0x80a2240 
<directory_packed_size>, 
      pack = 0x80a23a0 <directory_pack>, unpack = 0x80a1cb0 <directory_unpack>, 
      dump = 0x80a1ba0 <directory_dump>}, {new_seg = 0x80a25d0 <PackFile_Segment_new>, 
destroy = 0, 
      packed_size = 0, pack = 0, unpack = 0, dump = 0x80a1590 <default_dump>}, {
      new_seg = 0x80a2fa0 <fixup_new>, destroy = 0x80a2dd0 <fixup_destroy>, 
      packed_size = 0x80a2df0 <fixup_packed_size>, pack = 0x80a2ea0 <fixup_pack>, 
      unpack = 0x80a2fd0 <fixup_unpack>, dump = 0x80a1590 <default_dump>}, {
      new_seg = 0x80a36f0 <const_new>, destroy = 0x80a3720 <const_destroy>, 
      packed_size = 0x80dd6f0 <PackFile_ConstTable_pack_size>, 
      pack = 0x80dd750 <PackFile_ConstTable_pack>, unpack = 0x80a35b0 
<PackFile_ConstTable_unpack>, 
      dump = 0x80a1590 <default_dump>}, {new_seg = 0x80a2770 <byte_code_new>, 
      destroy = 0x80a2700 <byte_code_destroy>, packed_size = 0, pack = 0, unpack = 0, 
      dump = 0x80a1590 <default_dump>}, {new_seg = 0x80a2810 <pf_debug_new>, 
      destroy = 0x80a27e0 <pf_debug_destroy>, packed_size = 0x80a2840 
<pf_debug_packed_size>, 
      pack = 0x80a2860 <pf_debug_pack>, unpack = 0x80a28b0 <pf_debug_unpack>, 
      dump = 0x80a1590 <default_dump>}}, cur_cs = 0x95c3f68, const_table = 0x95c4030, 
  byte_code = 0xf535a0c0, eval_nr = 0, need_wordsize = 0, need_endianize = 0, 
  fetch_op = 0x80ee670 <fetch_op_le_4>, fetch_iv = 0, fetch_nv = 0}
(gdb) print *dir
$17 = {base = {pf = 0x95c3dc8, dir = 0x0, type = 0, name = 0x95c3f28 "DIRECTORY", 
op_count = 67404, 
    file_offset = 32, itype = 0, id = 0, size = 0, data = 0x0}, num_segments = 4, 
segments = 0x95f4750}
(gdb) up
#5  0x080e43b6 in Parrot_dod_trace_root (interpreter=0x940a008, trace_stack=1) at 
src/dod.c:331
(gdb) print *stash
Cannot access memory at address 0x0
(gdb) up
#6  0x080e44c4 in trace_active_PMCs (interpreter=0x940a008, trace_stack=1) at 
src/dod.c:370
(gdb) frame 0
#0  0x080e4169 in pobject_lives (interpreter=0x940a008, obj=0x11) at src/dod.c:198
(gdb) backtrace
#0  0x080e4169 in pobject_lives (interpreter=0x940a008, obj=0x11) at src/dod.c:198
#1  0x080a09da in mark_1_seg (interpreter=0x940a008, cs=0x95c3f68) at 
src/packfile.c:360
#2  0x080a0a34 in find_code_iter (seg=0x95c3f68, user_data=0x940a008) at 
src/packfile.c:375
#3  0x080a0ef8 in PackFile_map_segments (dir=0x95c3dc8, callback=0x80a09f0 
<find_code_iter>, 
    user_data=0x940a008) at src/packfile.c:687
#4  0x080a0a7f in mark_const_subs (interpreter=0x940a008) at src/packfile.c:399
#5  0x080e43b6 in Parrot_dod_trace_root (interpreter=0x940a008, trace_stack=1) at 
src/dod.c:331
#6  0x080e44c4 in trace_active_PMCs (interpreter=0x940a008, trace_stack=1) at 
src/dod.c:370
#7  0x080e4db6 in Parrot_dod_ms_run (interpreter=0x940a008, flags=1) at src/dod.c:1160
#8  0x080e4efd in Parrot_do_dod_run (interpreter=0x940a008, flags=1) at src/dod.c:1216
#9  0x080e2ed1 in more_traceable_objects (interpreter=0x940a008, pool=0x95ad050)
    at src/smallobject.c:117
#10 0x080e2f70 in gc_ms_get_free_object (interpreter=0x940a008, pool=0x95ad050)
    at src/smallobject.c:183
#11 0x080e3377 in get_free_buffer (interpreter=0x940a008, pool=0x95ad050) at 
src/headers.c:56
#12 0x080e39f8 in new_bufferlike_header (interpreter=0x940a008, size=96) at 
src/headers.c:464
#13 0x080a47b7 in cst_new_stack_chunk (interpreter=0x940a008, chunk=0x95ad290) at 
src/stack_common.c:87
#14 0x080a47fc in stack_prepare_push (interpreter=0x940a008, stack_p=0x940a290)
    at src/stack_common.c:109
#15 0x0809dd2a in Parrot_push_s (interpreter=0x940a008, where=0x940a1c8) at 
generic_register.c:51
#16 0x08109e5f in Parrot_savetop (cur_opcode=0xf538be10, interpreter=0x940a008) at 
stack.ops:337
#17 0x081799e5 in runops_slow_core (interpreter=0x940a008, pc=0xf538be10) at 
src/runops_cores.c:147
#18 0x081779c7 in runops_int (interpreter=0x940a008, offset=14981) at 
src/interpreter.c:809
#19 0x08178824 in runops (interpreter=0x940a008, offset=14981) at src/inter_run.c:69
#20 0x080dcefc in Parrot_runcode (interpreter=0x940a008, argc=1, argv=0xfeed4f08) at 
src/embed.c:750
#21 0x080dcd22 in Parrot_runcode (interpreter=0x940a008, argc=1, argv=0xfeed4f08) at 
src/embed.c:679
#22 0x0809ce25 in main (argc=1, argv=0xfeed4f08) at imcc/main.c:580
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb) quit

Debugger finished

Reply via email to