1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-24 07:20:27 +00:00

Address #1337 (leet!).

Changes a few scheduling details and adds a 0 byte explicitly to
symbols created via gensym.
This commit is contained in:
Calvin Rose 2023-12-16 16:15:46 -06:00
parent a0cb7514f1
commit a10b4f61d8
3 changed files with 33 additions and 28 deletions

View File

@ -2031,6 +2031,7 @@ void janet_ev_default_threaded_callback(JanetEVGenericMessage return_value) {
if (return_value.fiber == NULL) { if (return_value.fiber == NULL) {
return; return;
} }
if (janet_fiber_can_resume(return_value.fiber)) {
switch (return_value.tag) { switch (return_value.tag) {
default: default:
case JANET_EV_TCTAG_NIL: case JANET_EV_TCTAG_NIL:
@ -2059,6 +2060,7 @@ void janet_ev_default_threaded_callback(JanetEVGenericMessage return_value) {
janet_schedule(return_value.fiber, janet_wrap_boolean(return_value.argi)); janet_schedule(return_value.fiber, janet_wrap_boolean(return_value.argi));
break; break;
} }
}
janet_gcunroot(janet_wrap_fiber(return_value.fiber)); janet_gcunroot(janet_wrap_fiber(return_value.fiber));
} }

View File

@ -529,10 +529,12 @@ static void janet_proc_wait_cb(JanetEVGenericMessage args) {
JanetString s = janet_formatc("command failed with non-zero exit code %d", status); JanetString s = janet_formatc("command failed with non-zero exit code %d", status);
janet_cancel(args.fiber, janet_wrap_string(s)); janet_cancel(args.fiber, janet_wrap_string(s));
} else { } else {
if (janet_fiber_can_resume(args.fiber)) {
janet_schedule(args.fiber, janet_wrap_integer(status)); janet_schedule(args.fiber, janet_wrap_integer(status));
} }
} }
} }
}
#endif /* End ev check */ #endif /* End ev check */

View File

@ -233,6 +233,7 @@ const uint8_t *janet_symbol_gen(void) {
head->length = sizeof(janet_vm.gensym_counter) - 1; head->length = sizeof(janet_vm.gensym_counter) - 1;
head->hash = hash; head->hash = hash;
sym = (uint8_t *)(head->data); sym = (uint8_t *)(head->data);
sym[head->length] = 0;
memcpy(sym, janet_vm.gensym_counter, sizeof(janet_vm.gensym_counter)); memcpy(sym, janet_vm.gensym_counter, sizeof(janet_vm.gensym_counter));
janet_symcache_put((const uint8_t *)sym, bucket); janet_symcache_put((const uint8_t *)sym, bucket);
return (const uint8_t *)sym; return (const uint8_t *)sym;