mz_proc_thread* mzrt_proc_first_thread_init() { /* initialize mz_proc_thread struct for first thread that wasn't created with mz_proc_thread_create */ mz_proc_thread *thread = (mz_proc_thread*)malloc(sizeof(mz_proc_thread)); thread->threadid = mz_proc_thread_self(); proc_thread_self = thread; thread->refcount = 1; return thread; }
void fault_handler(int sn, struct siginfo *si, void *ctx) { void *p = si->si_addr; /* quick access to SIGSEGV info in GDB */ int c = si->si_code; #ifdef MZ_USE_PLACES int m = 0; #endif if (si->si_code != SEGV_ACCERR) { /*SEGV_MAPERR*/ if (c == SEGV_MAPERR) { printf("SIGSEGV MAPERR si_code %i fault on addr %p\n", c, p); } if (c == 0 ) { /* I have now idea why this happens on linux */ /* supposedly its coming from the user via kill */ /* so just ignore it. */ printf("SIGSEGV SI_USER SI_CODE %i fault on addr %p\n", c, p); printf("pid %i uid %i thread %lx\n", si->si_pid, si->si_uid, mz_proc_thread_self()); return; } if (c == 128 ) { printf("SIGSEGV SI_KERNEL SI_CODE %i fault on addr %p sent by kernel\n", c, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } if (!designate_modified(p)) { if (si->si_code == SEGV_ACCERR) { #ifdef MZ_USE_PLACES if(pagemap_find_page(MASTERGC->page_maps, p)) { m = 1; printf("ADDR %p OWNED BY MASTER %i\n", p, m); } #endif printf("SIGSEGV SEGV_ACCERR SI_CODE %i fault on %p\n", c, p); } else { printf("SIGSEGV ???? SI_CODE %i fault on %p\n", c, p); } abort(); } # define NEED_SIGSTACK # define NEED_SIGACTION # define USE_SIGACTON_SIGNAL_KIND SIGSEGV }
static void *place_start_proc_after_stack(void *data_arg, void *stack_base) { Place_Start_Data *place_data; Scheme_Object *place_main; Scheme_Object *a[2], *channel; mzrt_thread_id ptid; intptr_t rc = 0; ptid = mz_proc_thread_self(); place_data = (Place_Start_Data *) data_arg; data_arg = NULL; /* printf("Startin place: proc thread id%u\n", ptid); */ /* create pristine THREAD_LOCAL variables*/ null_out_runtime_globals(); /* scheme_make_thread behaves differently if the above global vars are not null */ scheme_place_instance_init(stack_base); a[0] = scheme_places_deep_copy(place_data->current_library_collection_paths); scheme_current_library_collection_paths(1, a); a[0] = scheme_places_deep_copy(place_data->module); a[1] = scheme_places_deep_copy(place_data->function); a[1] = scheme_intern_exact_symbol(SCHEME_SYM_VAL(a[1]), SCHEME_SYM_LEN(a[1])); if (!SAME_TYPE(SCHEME_TYPE(place_data->channel), scheme_place_bi_channel_type)) { channel = scheme_places_deep_copy(place_data->channel); } else { channel = place_data->channel; } mzrt_sema_post(place_data->ready); place_data = NULL; # ifdef MZ_PRECISE_GC /* this prevents a master collection attempt from deadlocking with the place_data->ready semaphore above */ GC_allow_master_gc_check(); # endif /* at point point, don't refer to place_data or its content anymore, because it's allocated in the other place */ scheme_set_root_param(MZCONFIG_EXIT_HANDLER, scheme_def_place_exit_proc); { Scheme_Thread * volatile p; mz_jmp_buf * volatile saved_error_buf; mz_jmp_buf new_error_buf; p = scheme_get_current_thread(); saved_error_buf = p->error_buf; p->error_buf = &new_error_buf; if (!scheme_setjmp(new_error_buf)) { Scheme_Object *dynamic_require; dynamic_require = scheme_builtin_value("dynamic-require"); place_main = scheme_apply(dynamic_require, 2, a); a[0] = channel; scheme_apply(place_main, 1, a); } else { rc = 1; } p->error_buf = saved_error_buf; } /*printf("Leavin place: proc thread id%u\n", ptid);*/ scheme_place_instance_destroy(); return (void*) rc; }
void fault_handler(int sn, siginfo_t *si, void *ctx) { void *p = si->si_addr; /* quick access to SIGSEGV info in GDB */ int c = si->si_code; #ifdef MZ_USE_PLACES int m = 0; #endif if (si->si_code != SEGV_ACCERR) { /*SEGV_MAPERR*/ if (c == SEGV_MAPERR) { printf("SIGSEGV MAPERR si_code %i fault on addr %p\n", c, p); /* SIGSEGV MAPERRs are invalid addresses. Possible reasons: An object is prematurely freed because it isn't getting marked correctly An unsafe operation was used incorrectly The stack grew beyond its bounds. */ } if (c == 0) { /* I have no idea why this happens on linux */ /* supposedly its coming from the user via kill */ /* so just ignore it. It appears when */ /* running w/ places in GDB */ printf("SIGSEGV SI_USER SI_ERRNO %i fault on addr %p\n", si->si_errno, p); #ifdef MZ_USE_PLACES printf("pid %i uid %i thread %lx\n", si->si_pid, si->si_uid, mz_proc_thread_self()); #else printf("pid %i uid %i\n", si->si_pid, si->si_uid); #endif return; } if (c == 128) { printf("SIGSEGV SI_KERNEL SI_ERRNO %i fault on addr %p\n", si->si_errno, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } if (!designate_modified(p)) { if (si->si_code == SEGV_ACCERR) { #ifdef MZ_USE_PLACES if(pagemap_find_page(MASTERGC->page_maps, p)) { m = 1; printf("ADDR %p OWNED BY MASTER %i\n", p, m); } #endif printf("SIGSEGV SEGV_ACCERR SI_CODE %i fault on %p\n", c, p); } else { printf("SIGSEGV ???? SI_CODE %i fault on %p\n", c, p); } #if WAIT_FOR_GDB launchgdb(); #endif abort(); } # define NEED_SIGSTACK # define NEED_SIGACTION # define USE_SIGACTON_SIGNAL_KIND SIGSEGV }