From de6ec47f9e872ab781bc322f47a91824471b5276 Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Mon, 19 Sep 2016 17:17:42 -0700 Subject: [PATCH] Add a recursion depth for serialization to prevent infinite loops. (#440) --- test/runtest.py | 33 +++++++++++++++++++++++++++++++++ thirdparty/numbuf | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/test/runtest.py b/test/runtest.py index 5706b2889..3f8a2b8e5 100644 --- a/test/runtest.py +++ b/test/runtest.py @@ -110,6 +110,39 @@ except AttributeError: cloudpickle_command = "sudo pip install --upgrade git+git://github.com/cloudpipe/cloudpickle.git@0d225a4695f1f65ae1cbb2e0bbc145e10167cce4" raise Exception("You have an older version of cloudpickle that is not able to serialize namedtuples. Try running \n\n{}\n\n".format(cloudpickle_command)) +class SerializationTest(unittest.TestCase): + + def testRecursiveObjects(self): + ray.init(start_ray_local=True, num_workers=0) + + class ClassA(object): + pass + + ray.register_class(ClassA) + + # Make a list that contains itself. + l = [] + l.append(l) + # Make an object that contains itself as a field. + a1 = ClassA() + a1.field = a1 + # Make two objects that contain each other as fields. + a2 = ClassA() + a3 = ClassA() + a2.field = a3 + a3.field = a2 + # Make a dictionary that contains itself. + d1 = {} + d1["key"] = d1 + # Create a list of recursive objects. + recursive_objects = [l, a1, a2, a3, d1] + + # Check that exceptions are thrown when we serialize the recursive objects. + for obj in recursive_objects: + self.assertRaises(Exception, lambda : ray.put(obj)) + + ray.worker.cleanup() + class ObjStoreTest(unittest.TestCase): # Test setting up object stores, transfering data between them and retrieving data to a client diff --git a/thirdparty/numbuf b/thirdparty/numbuf index 052773649..7055c6f79 160000 --- a/thirdparty/numbuf +++ b/thirdparty/numbuf @@ -1 +1 @@ -Subproject commit 0527736490b2bd1d44ebfbbd17e298f5863d7dfc +Subproject commit 7055c6f793f8b0aadb71cef9c81dce615e0cc77f