Added failed recursion test #34

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

I added the test to look for recursive objects, however it's causing a seg fault soon after. I can try to actually fix the problem but it might end up being obvious to you why it's seg faulting. To repeat my thoughts about how to fix this:
Keep a hash of all objects being looked at during the recurse and throw an exception if you see the same object again.

Change this:

template<typename T> void BSONSerializer<T>::SerializeValue(void* typeLocation, const Handle<Value>& value)

to something like this. I have not looked that close at the code but it should work in theory to keep a hash of identity hash values for all the objects serialized within a single serialize document or calculate size method call.

template<typename T> void BSONSerializer<T>::SerializeValue(void* typeLocation, const Handle<Value>& value, Handle<Object>& check)
{
  if (value->IsObject()) {
    Handle<Object>& object = value->ToObject();
    int hash = object->GetIdentityHash();
    if (object->Has(hash))
      return VException("recursive structure");
    check->ForceSet(hash, true);
  }
Member

christkv commented Oct 1, 2013

closing as not fixing for now, requires a complete re-engineering of the driver internals

christkv closed this Oct 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment