Skip to content

Commit c16bfbe

Browse files
committed
rt: Stop logging on the Rust stack. Closes #1478
1 parent 27ab663 commit c16bfbe

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/rt/rust_log.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ rust_log::trace_ln(char *prefix, char *message) {
106106
void
107107
rust_log::trace_ln(rust_task *task, uint32_t level, char *message) {
108108

109+
if (task) {
110+
// There is not enough room to be logging on the rust stack
111+
assert(!task->on_rust_stack() && "logging on rust stack");
112+
}
109113

110114
// FIXME: The scheduler and task names used to have meaning,
111115
// but they are always equal to 'main' currently

src/rt/rust_task.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ void task_start_wrapper(spawn_args *a)
196196
if(env) {
197197
// free the environment (which should be a unique closure).
198198
const type_desc *td = env->td;
199-
LOG(task, task, "Freeing env %p with td %p", env, td);
200199
td->drop_glue(NULL, NULL, td->first_param, box_body(env));
201200
upcall_free_shared_type_desc(env->td);
202201
upcall_shared_free(env);
@@ -720,6 +719,11 @@ Returns true if we're currently running on the Rust stack
720719
*/
721720
bool
722721
rust_task::on_rust_stack() {
722+
if (stk == NULL) {
723+
// This only happens during construction
724+
return false;
725+
}
726+
723727
uintptr_t sp = get_sp();
724728
bool in_first_segment = sp_in_stk_seg(sp, stk);
725729
if (in_first_segment) {

0 commit comments

Comments
 (0)