Skip to content

Conversation

davidbaraff
Copy link
Contributor

Fixes cycles in SerializableObjects cause crashes #847

Modified the logic near #ifdef INSTANCING_SUPPORT to make use of the same table for checking for already encountered objects; however, because we only want to detect cycle and let mere instancing pass through (i.e. we don't demand things be a tree, we just demand they be acyclic) we remove an object from the table as we leave the function where we first encountered it.

In this way, we should be back to not being able to crash the system by writing bad Python code.

New tests (in tests.test_serializable_object.SerializableObjTest):
test_instancing_without_instancing_support
test_cycle_detection

Copy link
Collaborator

@meshula meshula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this solution, thank you!

Comment on lines +192 to +196
# Note: If we ever enable INSTANCING_SUPPORT in the C++ code,
# then modify the code below to be:
# oCopy = o.clone()
# self.assertTrue(oCopy is oCopy.metadata["myself"])
with self.assertRaises(ValueError):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah great, thanks for putting these comments in, very helpful!

Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ssteinbach ssteinbach merged commit dd983aa into AcademySoftwareFoundation:master Jan 21, 2021
@ssteinbach ssteinbach added this to the Public Beta 14 milestone Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants