~ chicken-core (chicken-5) df93ff11474ec63f4b8b0cd49b7842bef5cdc894


commit df93ff11474ec63f4b8b0cd49b7842bef5cdc894
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Mon Jan 1 17:15:12 2018 +0100
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Mon Jan 1 17:15:12 2018 +0100

    Fix a segfault when profiling CHICKEN itself
    
    The trace buffer will be filled during initialization, before the
    current thread symbol is set up yet.  Then, when we look up the
    thread identifier, this may fail.  Instead, we'll store #f as the
    identifier in such cases.

diff --git a/runtime.c b/runtime.c
index 2cb1988b..ab411903 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4448,7 +4448,7 @@ C_regparm void C_fcall C_trace(C_char *name)
   trace_buffer_top->cooked1 = C_SCHEME_FALSE;
   trace_buffer_top->cooked2 = C_SCHEME_FALSE;
   thread = C_block_item(current_thread_symbol, 0);
-  trace_buffer_top->thread = C_thread_id(thread);
+  trace_buffer_top->thread = C_and(C_blockp(thread), C_thread_id(thread));
   ++trace_buffer_top;
 }
 
Trap