BhallaLab / moose-core

C++ basecode and python scripting interface
https://moose.ncbs.res.in
GNU General Public License v3.0
15 stars 26 forks source link

Segfault when accessing `e1` and `e2` field of Msg #28

Open dilawar opened 9 years ago

dilawar commented 9 years ago

Following snippet loads a kinekit model and prints sources and destinations of each message:

import pylab
import moose
import numpy as np

# Import all helper functions.
modelFile = './stargazin_synapse.g'
modelPathInMoose = 'model'
method = 'old_gssa'
modelId = moose.loadModel(modelFile, modelPathInMoose, method)
msgs =  moose.wildcardFind('/##[TYPE=OneToAllMsg]')

for m in msgs:
    try: print m.e1
    except: pass
    try: print m.e2
    except: pass

# This does not
for m in msgs:
    print m.e1, m.e2

Function Msg::getE1 in Msg.cpp cause seg-fault because data-member e1_ is a garbage value (sometimes NULL).

Probably Eref::data() is returning NULL

Breakpoint 1, GetOpFunc<Msg, Id>::returnOp (this=0xa9f2c0, e=...)
    at /public/dilawars/moose3.0.1/basecode/OpFunc.h:146
146             return ( reinterpret_cast< T* >( e.data() )->*func_)();
4: e = (const Eref &) @0x7fffffffd100: {
  e_ = 0xba55f0, 
  i_ = 17, 
  f_ = 0
}
3: e.data() = 0x14cc8d0 "\260?\242\365\377\177"
(gdb) 
Continuing.
<moose.vec: class=CubeMesh, id=414, path=/model[0]/kinetics>

Breakpoint 1, GetOpFunc<Msg, Id>::returnOp (this=0xa9f2c0, e=...)
    at /public/dilawars/moose3.0.1/basecode/OpFunc.h:146
146             return ( reinterpret_cast< T* >( e.data() )->*func_)();
4: e = (const Eref &) @0x7fffffffd100: {
  e_ = 0xba57f0, 
  i_ = 0, 
  f_ = 0
}
3: e.data() = 0x0
(gdb) print e
$4 = (const Eref &) @0x7fffffffd100: {
  e_ = 0xba57f0, 
  i_ = 0, 
  f_ = 0
}

NOTE: migrated from sourceforge.

dilawar commented 9 years ago

Seg-fault only on MsgType 'OneToAllMsg'. Msg 'OneToOne' are acting as expected.

dilawar commented 7 years ago

Model file is attached. This bug/bahaviour is still valid. It is not critical for simulation. But can be critical when these fields are accessed for debugging purpose.

stargazin_synapse.g.txt

github-actions[bot] commented 4 years ago

Stale issue message