@@ -110,16 +110,17 @@ class ExceptionSink:
110
110
# Where to log stacktraces to in a SIGUSR2 handler.
111
111
_interactive_output_stream = None
112
112
113
- # An instance of `SignalHandler` which is invoked to handle a static set of specific
114
- # nonfatal signals (these signal handlers are allowed to make pants exit, but unlike SIGSEGV they
115
- # don't need to exit immediately).
113
+ # An instance of `SignalHandler` which is invoked to handle a static set of specific nonfatal
114
+ # signals (these signal handlers are allowed to make pants exit, but unlike SIGSEGV they don't
115
+ # need to exit immediately).
116
116
_signal_handler : SignalHandler = SignalHandler (pantsd_instance = False )
117
117
118
118
# These persistent open file descriptors are kept so the signal handler can do almost no work
119
119
# (and lets faulthandler figure out signal safety).
120
120
_pid_specific_error_fileobj = None
121
121
_shared_error_fileobj = None
122
122
123
+ # Set in methods on SignalHandler and exposed to the engine rust code.
123
124
_signal_sent : Optional [int ] = None
124
125
125
126
def __new__ (cls , * args , ** kwargs ):
@@ -360,7 +361,8 @@ def log_exception(cls, exc_class=None, exc=None, tb=None, add_newline=False):
360
361
361
362
extra_err_msg = None
362
363
try :
363
- # Always output the unhandled exception details into a log file, including the traceback.
364
+ # Always output the unhandled exception details into a log file, including the
365
+ # traceback.
364
366
exception_log_entry = cls ._format_unhandled_exception_log (
365
367
exc , tb , add_newline , should_print_backtrace = True
366
368
)
@@ -369,8 +371,13 @@ def log_exception(cls, exc_class=None, exc=None, tb=None, add_newline=False):
369
371
extra_err_msg = "Additional error logging unhandled exception {}: {}" .format (exc , e )
370
372
logger .error (extra_err_msg )
371
373
372
- # Generate an unhandled exception report fit to be printed to the terminal.
373
- logger .exception (exc )
374
+ # The rust logger implementation will have its own stacktrace, but at import time, we want
375
+ # to be able to see any stacktrace to know where the error is being raised, so we reproduce
376
+ # it here.
377
+ exception_log_entry = cls ._format_unhandled_exception_log (
378
+ exc , tb , add_newline , should_print_backtrace = True
379
+ )
380
+ logger .exception (exception_log_entry )
374
381
375
382
@classmethod
376
383
def _handle_signal_gracefully (cls , signum , signame , traceback_lines ):
0 commit comments