numenta/nupic.core-legacy

Fix NuPIC capnproto failure: two different compiled-in type have the same type ID

vitaly-krugl opened this issue · 0 comments

Chetan first ran into this while trying to implement capnp serialization here: numenta/nupic-legacy#2944. This nupic PR pairs with nupic.core commit 7de0c59.

This task is to verify whether the problem still exists in the current nupic + nupic.core and propose a solution.

Reproduced with the old code:
NetworkCheckpointTest.testTPRegion
E       RuntimeError: /Users/vkruglikov/nta/nupic.core/build/scripts/ThirdParty/Source/CapnProto/c++/src/capnp/schema-loader.c++:1337: failed: expected slot->canCastTo == nativeSchema; two different compiled-in type have the same type ID; nativeSchema->id = 12019543866721312306; readMessageUnchecked<schema::Node>(nativeSchema->encodedNode).getDisplayName() = nupic/proto/RandomProto.capnp:RandomProto; readMessageUnchecked<schema::Node>(slot->canCastTo->encodedNode).getDisplayName() = nupic/proto/RandomProto.capnp:RandomProto
E       stack: 0x1067d9d69 0x1067d9e09 0x1067d60b0 0x1067a392b 0x106785dad 0x106784439 0x10678fc62 0x1065b8064 0x1046f710c 0x1046f3a1e 0x1046fa442 0x1046f6eae 0x1046fa4d5 0x1046f6eae 0x1046fa4d5 0x1046f6eae
E       capnp::SchemaLoader::Impl::loadNative(capnp::_::RawSchema const*) (in _math.so) + 489: called here
E       capnp::SchemaLoader::loadNative(capnp::_::RawSchema const*) (in _math.so) + 82: called here
E       _wrap_Random_write(_object*, _object*) (in _math.so) + 932: called here
E       PyEval_EvalFrameEx (in Python) + 13560: called here
E       PyEval_EvalCodeEx (in Python) + 1617: called here
E       0x00000001046fa442 (in Python) + 117: called here
E       PyEval_EvalFrameEx (in Python) + 12954: called here
E       0x00000001046fa4d5 (in Python) + 264: called here

The problem was that a dynamic capnp schema object with the same ID was being registered with a shared capnp library from two different nupic.bindings extensions, each such schema object having a different memory address, thus causing the exception in capnp.