1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-01 04:19:55 +00:00

Fix channel packing bug.

This commit is contained in:
Calvin Rose 2021-12-04 10:28:00 -06:00
parent 8ba142bcf4
commit 868cdb9f8b
2 changed files with 10 additions and 1 deletions

View File

@ -620,7 +620,7 @@ static int janet_chan_unpack(JanetChannel *chan, Janet *x, int is_cleanup) {
return 1; return 1;
case JANET_BUFFER: { case JANET_BUFFER: {
JanetBuffer *buf = janet_unwrap_buffer(*x); JanetBuffer *buf = janet_unwrap_buffer(*x);
int flags = is_cleanup ? JANET_MARSHAL_UNSAFE : (JANET_MARSHAL_UNSAFE | JANET_MARSHAL_DECREF); int flags = is_cleanup ? (JANET_MARSHAL_UNSAFE | JANET_MARSHAL_DECREF) : JANET_MARSHAL_UNSAFE;
*x = janet_unmarshal(buf->data, buf->count, flags, NULL, NULL); *x = janet_unmarshal(buf->data, buf->count, flags, NULL, NULL);
janet_buffer_deinit(buf); janet_buffer_deinit(buf);
janet_free(buf); janet_free(buf);

View File

@ -27,5 +27,14 @@
(assert (< 2605.1158 (math/log-gamma 500) 2605.1159) (assert (< 2605.1158 (math/log-gamma 500) 2605.1159)
"math/log-gamma") "math/log-gamma")
(def ch (ev/thread-chan 2))
(def att (ev/thread-chan 109))
(assert att "`att` was nil after creation")
(ev/give ch att)
(ev/do-thread
(print "started thread")
(assert (ev/take ch) "channel packing bug for threaded abstracts on threaded channels."))
(print "done")
(end-suite) (end-suite)