[CM] possible bug in hook invocation

Woody Douglass wdouglass at carnegierobotics.com
Thu Jun 9 07:15:01 PDT 2022


with the current master of s7 git, i'm still having the problem. when
the system crashes, the following is printed

```
op_safe_closure_p_a_1[83596]: opt2: 0x2cac0b30->(nil) wants opt2_fx,
debugger bits are 20000004  opt3_set opt3_location but expects 262144
opt2_fx
```

the type is 1, so maybe it's been gc'd and then reallocated?
```
(gdb) p sc->code[0]     
$3 = {tf = {flag = 13979174299934918657, signed_flag =
-4467569773774632959, type_field = 1 '\001', sflag = 2049, opts = {
      unused_low_flag = 14944257, opt_choice = 246, high_flag =
49664}}, object = {number = {integer_value = 749583392, 
      real_value = 3.7034340268035228e-315, fraction_value = {numerator
= 749583392, denominator = 749452976}, complex_value = {
        rl = 3.7034340268035228e-315, im = 3.7027896861508425e-315}},
number_name = {unused1 = 749583392, unused2 = 749452976, 
      name = "\260\n\254,", '\000' <repeats 12 times>,
"\371\000\000\003\340s\002"}, prt = {port = 0x2cadbc20, 
      data = 0x2cabbeb0 "\001", size = 749472432, point = 0, block =
0x273e0030000f9}, chr = {c = 32 ' ', up_c = 188 '\274', 
      length = 0, alpha_c = 176, digit_c = 190, space_c = 171, upper_c
= 44, lower_c = false, 
      c_name = "\000\000\000\260\n\254,\000\000\000\000"}, cptr =
{c_pointer = 0x2cadbc20, c_type = 0x2cabbeb0, info = 0x2cac0ab0, 
      weak1 = 0x0, weak2 = 0x273e0030000f9}, vector = {length =
749583392, elements = {objects = 0x2cabbeb0, ints = 0x2cabbeb0, 
        floats = 0x2cabbeb0, bytes = 0x2cabbeb0 "\001"}, block =
0x2cac0ab0, vget = 0x0, setv = {vset = 0x273e0030000f9, 
        fset = 0x273e0030000f9}}, stk = {length = 749583392, objects =
0x2cabbeb0, block = 0x2cac0ab0, top = 0, 
      flags = 690355913621753}, hasher = {mask = 749583392, elements =
0x2cabbeb0, hash_func = 0x2cac0ab0, loc = 0x0, 
      block = 0x273e0030000f9}, iter = {obj = 0x2cadbc20, cur =
0x2cabbeb0, lc = {loc = 749472432, lcur = 0x2cac0ab0}, lw = {len = 0, 
        slow = 0x0, hcur = 0x0}, next = 0x273e0030000f9}, fnc = {c_proc
= 0x2cadbc20, ff = 0x2cabbeb0, required_args = 749472432, 
      optional_args = 0, all_args = 690355913621753}, cons = {car =
0x2cadbc20, cdr = 0x2cabbeb0, opt1 = 0x2cac0ab0, o2 = {opt2 = 0x0, 
        n = 0}, o3 = {opt3 = 0x273e0030000f9, n = 690355913621753,
opt_type = 249 '\371'}}, sym_cons = {unused_car = 0x2cadbc20, 
      unused_cdr = 0x2cabbeb0, hash = 749472432, fstr = 0x0, location =
690355913621753}, func = {args = 0x2cadbc20, 
      body = 0x2cabbeb0, env = 0x2cac0ab0, setter = 0x0, arity =
50331897}, string = {length = 749583392, svalue = 0x2cabbeb0 "\001", 
      hash = 749472432, block = 0x0, gensym_block = 0x273e0030000f9},
sym = {name = 0x2cadbc20, global_slot = 0x2cabbeb0, 
      local_slot = 0x2cac0ab0, id = 0, ctr = 50331897, tag = 160736},
syn = {symbol = 0x2cadbc20, op = 749452976, 
      min_args = 749472432, max_args = 0, documentation = 0x0}, slt =
{sym = 0x2cadbc20, val = 0x2cabbeb0, nxt = 0x2cac0ab0, 
      pending_value = 0x0, expr = 0x273e0030000f9}, envr = {slots =
0x2cadbc20, nxt = 0x2cabbeb0, id = 749472432, edat = {efnc = {
          function = 0x0, line = 50331897, file = 160736}, dox = {dox1
= 0x0, dox2 = 0x273e0030000f9}, key = 0}}, unq = {
      car = 0x2cadbc20, cdr = 0x2cabbeb0, unused_let_id = 749472432,
name = 0x0, len = 690355913621753}, undef = {
      name = 0x2cadbc20 "\n", len = 749452976}, eof = {name =
0x2cadbc20 "\n", len = 749452976}, ctr = {result = 0x2cadbc20, 
      list = 0x2cabbeb0, env = 0x2cac0ab0, slots = 0x0, cap =
690355913621753}, rng = {seed = 749583392, carry = 749452976}, c_obj =
{
      type = 749583392, value = 0x2cabbeb0, e = 0x2cac0ab0, sc = 0x0},
cwcc = {block = 0x2cadbc20, stack = 0x2cabbeb0, 
      op_stack = 0x2cac0ab0, stack_start = 0x0, stack_end =
0x273e0030000f9}, rexit = {goto_loc = 749583392, op_stack_loc =
749452976, 
      active = 176, name = 0x0}, rcatch = {goto_loc = 749583392,
op_stack_loc = 749452976, tag = 0x2cac0ab0, handler = 0x0, 
      cstack = 0x273e0030000f9}, winder = {in = 0x2cadbc20, out =
0x2cabbeb0, body = 0x2cac0ab0, state = DWIND_INIT}}, 
  current_alloc_line = 90969, previous_alloc_line = 0, uses = 1,
explicit_free_line = 0, gc_line = 0, current_alloc_type = 2097153, 
  previous_alloc_type = 0, debugger_bits = 536870981,
current_alloc_func = 0x7fefd8 <__FUNCTION__.69573> "eval", 
  previous_alloc_func = 0x0, gc_func = 0x0}

```


On Wed, 2022-06-08 at 14:45 -0700, bil at ccrma.Stanford.EDU wrote:
> This could be a GC problem, but it's a circuitous path if so.
> Can you send me enough code to try to recreate the segfault?
> On the other question, a lambda form is only deemed safe
> if its body is safe.  If you hit the segfault in gdb,
> a stacktrace would be helpful.  To see if the GC is
> the problem, build s7 with -g3 and S7_DEBUGGING=1, then
> when you crash in safe_closure_p_a_1
> 
> p sc->code[0]
> 
> It should be a "closure" in s7 terminology (type==39 in the gdb
> output).  If it's free (type==0), go to the end of the gdb
> printout, and you'll see where the GC freed it and so on.
> (Actually S7_DEBUGGING will tell you most of this before
> falling into gdb).
> 



More information about the Cmdist mailing list