opencog / atomspace

The OpenCog (hyper-)graph database and graph rewriting system
https://wiki.opencog.org/w/AtomSpace
Other
801 stars 225 forks source link

Bug with deleting atom spanning multiple atomspace #9

Closed williampma closed 9 years ago

williampma commented 9 years ago

Not sure whether to put this in "atomspace" or "opencog".

Have a module that does the following, which get called in cogserver's scheme shell

    AtomSpace* temp = new AtomSpace(_as);   // temp has _as parent

    Handle h1 = _as->addAtom(createNode(CONCEPT_NODE, "aaa"));
    Handle h2 = temp->addAtom(createNode(CONCEPT_NODE, "bbb"));
    temp->addAtom(createLink(LIST_LINK, h1, h2));

    delete temp;
    return;

then do cog-prt-atomspace, cogserver crashes.

linas commented 9 years ago

Could you provide a backtrace?

I just extended MultiSpaceUTest.cxxtest to test this, it doesn't reproduce.

I don't understand it. cog-prt-atomspace calls line 192 of guile/SchemeSmobAtom.cc but I don't see how that atomspace pointer could be corrupted.

williampma commented 9 years ago
[2015-05-06 03:11:51:838] [ERROR] Caught signal 11 (Segmentation fault) on thread 140288865597184
    Stack Trace:
    2: ./opencog/server/cogserver (opencog::Logger::Base::~Base() +0x5e) [0x407f1e]
    3: ./opencog/server/cogserver (sighand(int) +0xe9) [0x407559]
    4: /lib/x86_64-linux-gnu/libc.so.6 (x +0x36c30) [0x7f97aba95c30]
    5: /usr/local/lib/opencog/libatomspace.so (opencog::Handle::Handle(std::shared_ptr<opencog::Atom> const&) +0x3) [0x7f97ab815bc3]
    6: /usr/local/lib/opencog/libsmob.so (opencog::SchemeSmob::ss_incoming_set(scm_unused_struct*) +0x144) [0x7f97aaf694a4]
    7: /usr/lib/libguile-2.0.so.22 (� +0xecc15) [0x7f97a8e06c15]
    8: /usr/lib/libguile-2.0.so.22 (� +0x27) [0x7f97a8d7e747]
    9: /usr/local/lib/opencog/libsmob.so (opencog::SchemeSmob::ss_map_type(scm_unused_struct*, scm_unused_struct*) +0x30e) [0x7f97aaf69f7e]
    10: /usr/lib/libguile-2.0.so.22 (� +0xecc00) [0x7f97a8e06c00]
    11: /usr/lib/libguile-2.0.so.22 (� +0x27) [0x7f97a8d7e747]
    12: /usr/lib/libguile-2.0.so.22 (� +0xecc00) [0x7f97a8e06c00]
    13: /usr/lib/libguile-2.0.so.22 (� +0x2e) [0x7f97a8d7e81e]
    14: /usr/lib/libguile-2.0.so.22 (� +0xecc00) [0x7f97a8e06c00]
    15: /usr/lib/libguile-2.0.so.22 (� +0x33) [0x7f97a8d7e863]
    16: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::do_eval(std::string const&) +0xc1) [0x7f97aaf61f81]
    17: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::c_wrap_eval(void*) +0x33) [0x7f97aaf620a3]
    18: /usr/lib/libguile-2.0.so.22 (� +0x5b2ca) [0x7f97a8d752ca]
    19: /usr/lib/libguile-2.0.so.22 (� +0xecc00) [0x7f97a8e06c00]
    20: /usr/lib/libguile-2.0.so.22 (� +0x33) [0x7f97a8d7e863]
    21: /usr/lib/libguile-2.0.so.22 (� +0x5b9ff) [0x7f97a8d759ff]
    22: /usr/lib/libguile-2.0.so.22 (� +0x35) [0x7f97a8d75a95]
    23: /usr/lib/x86_64-linux-gnu/libgc.so.1 (� +0x60) [0x7f97a7f2f950]
    24: /usr/lib/libguile-2.0.so.22 (� +0xd47d1) [0x7f97a8dee7d1]
    25: /usr/lib/x86_64-linux-gnu/libgc.so.1 (� +0x12) [0x7f97a7f29fe2]
    26: /usr/lib/libguile-2.0.so.22 (� +0x28) [0x7f97a8deeb48]
    27: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::eval_expr(std::string const&) +0x2e) [0x7f97aaf6204e]
    28: ./opencog/shell/libscheme-shell.so (� +0x7e14) [0x7f979d075e14]
    29: /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb1bf0) [0x7f97ac0ecbf0]
    30: /lib/x86_64-linux-gnu/libpthread.so.0 (� +0x8182) [0x7f97aad3d182]
    31: /lib/x86_64-linux-gnu/libc.so.6 (� +0x6d) [0x7f97abb59efd]

The scheme primitive (module) that calls the multiple atomspace codes at the top returns successfully. It is only when I try to print the atomspace content that the server crashes.

linas commented 9 years ago

Yeah. I've decided that the way the atomspace percolates through the code is nutty, and needs simplifcation. There's a lot of nuttiness in there, that need not be.

Could you install libbfd and liberty, so as to get nice stack traces? (you would do this and rebuild cogutils, which is where the stack-race printing is done).

linas commented 9 years ago

I just now pushed a patch that maybe fixes this bug. Not sure. ss_incoming_set was old and crufty, left-over from the bad old days

williampma commented 9 years ago

Yes, that seems to have fixed it, thanks!