diff --git a/src/core/marsh.c b/src/core/marsh.c index b3c6e950..99a40d31 100644 --- a/src/core/marsh.c +++ b/src/core/marsh.c @@ -802,6 +802,9 @@ static const uint8_t *unmarshal_one_fiber( fiber->data = NULL; fiber->child = NULL; + /* Push fiber to seen stack */ + janet_array_push(&st->lookup, janet_wrap_fiber(fiber)); + /* Set frame later so fiber can be GCed at anytime if unmarshalling fails */ int32_t frame = 0; int32_t stack = 0; diff --git a/test/suite1.janet b/test/suite1.janet index a48d30df..a8da2311 100644 --- a/test/suite1.janet +++ b/test/suite1.janet @@ -175,6 +175,10 @@ (testmarsh (fiber/new (fn [] (yield 1) 2)) "marshal simple fiber 1") (testmarsh (fiber/new (fn [&] (yield 1) 2)) "marshal simple fiber 2") +(def strct {:a @[nil]}) +(put (strct :a) 0 strct) +(testmarsh strct "cyclic struct") + # Large functions (def manydefs (seq [i :range [0 300]] (tuple 'def (gensym) (string "value_" i)))) (array/push manydefs (tuple * 10000 3 5 7 9)) diff --git a/test/suite4.janet b/test/suite4.janet index 5fbb9055..d19eb9cc 100644 --- a/test/suite4.janet +++ b/test/suite4.janet @@ -43,5 +43,17 @@ (assert (deep= (range 5 10) @[5 6 7 8 9]) "range 2 arguments") (assert (deep= (range 5 10 2) @[5 7 9]) "range 3 arguments") +# More marshalling code + +(defn check-image + "Run a marshaling test using the make-image and load-image functions." + [x] + (def src (make-image x)) + (load-image src)) + +(check-image (fn [] (fn [] 1))) +(check-image (fiber/new (fn [] (fn [] 1)))) +(check-image (fiber/new (fn [] (fiber/new (fn [] 1))))) + (end-suite)