Also send SIGSEGV on EACCES fault
[akaros.git] / user / pthread / pthread.c
index c039a33..924db08 100644 (file)
@@ -74,10 +74,17 @@ static void __pthread_trigger_posix_signal(pthread_t thread, int signo,
                                            struct siginfo *info)
 {
        int vcoreid = vcore_id();
+       struct user_context *ctx;
+       if (current_uthread) {
+               struct preempt_data *vcpd = vcpd_of(vcoreid);
+        ctx = &vcpd->uthread_ctx;
+       } else {
+               ctx = &thread->uthread.u_ctx;
+       }
+
        void *temp_tls_desc = get_tls_desc(vcoreid);
-       struct uthread *uthread = (struct uthread*)thread;
-       set_tls_desc(uthread->tls_desc, vcore_id());
-       trigger_posix_signal(signo, info, &uthread->u_ctx);
+       set_tls_desc(thread->uthread.tls_desc, vcoreid);
+       trigger_posix_signal(signo, info, ctx);
        set_tls_desc(temp_tls_desc, vcoreid);
 }
 
@@ -306,8 +313,8 @@ void pth_thread_refl_fault(struct uthread *uthread, unsigned int trap_nr,
        TAILQ_REMOVE(&active_queue, pthread, next);
        mcs_pdr_unlock(&queue_lock);
 
-       if (trap_nr != 14) {
-               printf("Pthread has unhandled fault\n");
+       if (trap_nr != 14 && trap_nr != 13) {
+               printf("Pthread has unhandled fault: %d\n", trap_nr);
                print_user_context(&uthread->u_ctx);
                exit(-1);
        }