mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 16:40:27 +00:00
Address #53 - marshalling fiber strangeness
The unmarshaller was not tracking fibers in references.
This commit is contained in:
parent
8c67bf82f6
commit
1147482e62
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user