From 8c4b37178c8e7cfcbb37682180c697cb6e55cb34 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 19 Apr 2025 22:24:40 +0200 Subject: libdiskfs: Fix catching exceptions This fixes making diskfs_catch_exception recursive, catching the last fault exception, and fixes callers. --- libdiskfs/disk-pager.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libdiskfs/disk-pager.c') diff --git a/libdiskfs/disk-pager.c b/libdiskfs/disk-pager.c index 7af0e3ba..886ce157 100644 --- a/libdiskfs/disk-pager.c +++ b/libdiskfs/disk-pager.c @@ -84,6 +84,7 @@ diskfs_start_disk_pager (struct user_pager_info *upi, static void fault_handler (int sig, long int sigcode, struct sigcontext *scp) { + jmp_buf *env; error_t err; #ifndef NDEBUG @@ -102,8 +103,10 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp) } #endif + env = &diskfs_exception_diu->env; + /* Clear the record, since the faulting thread will not. */ - diskfs_exception_diu = NULL; + diskfs_exception_diu = diskfs_exception_diu->next; /* Fetch the error code from the pager. */ assert_backtrace (scp->sc_error == EKERN_MEMORY_ERROR); @@ -111,5 +114,5 @@ fault_handler (int sig, long int sigcode, struct sigcontext *scp) assert_backtrace (err); /* Make `diskfault_catch' return the error code. */ - longjmp (diskfs_exception_diu->env, err); + longjmp (*env, err); } -- cgit v1.2.3