diff --git a/core/src/statusbar.sld b/core/src/statusbar.sld index e2be98b..e3fb628 100644 --- a/core/src/statusbar.sld +++ b/core/src/statusbar.sld @@ -40,7 +40,22 @@ (when start (redraw-status-bar)) (mutex-unlock! mutex)))) - (make-output-port (lambda (str) (mutex-lock! mutex) (write-data (string->utf8 str) 0)) close-this-port)) + (make-output-port + (lambda (str) + ; In some rare cases, due to how Chicken Scheme handles errors, + ; it is possible for us to seemingly recursively have been called + ; while in the error handler. If this is the case (e.g. we are about + ; to attempt to lock a mutex we ostensibly own), bail out and unlock + ; the mutex. + (when (eq? (mutex-state mutex) (current-thread)) + (mutex-unlock! mutex)) + + ; Try to force-disable the error handling behavior. + (##sys#print-length-limit #f) + + (mutex-lock! mutex) + (write-data (string->utf8 str) 0)) + close-this-port)) ;; Creates a status bar. Ensures redraws are limited where necessary, and will erase itself before printing `stdout`. `stderr` output will be put in the statusbar. ;; if `print-logs` is `#t`, will output stderr to the display.