FairRoot
FairRoot copied to clipboard
LOG(fatal) is supposed to throw an exception but it never throws because of abort from fclose(stderr)
Describe the bug https://github.com/FairRootGroup/FairRoot/blob/fa7108b45684c729c2e88b12d7fbf4bbb5a4dc65/fairtools/FairLogger.cxx#L192-L203
Here the program somehow call the abort
when calling fclose(stderr)
in the if statement. Therefore, it never reaches to the throwing line.
To Reproduce Add a printout just above the throw statement and the printout message never gets printed.
Expected behavior Let it throw
A different idea:
a LOG
call should never throw (unless it can't actually log) because of a severity level. It's job is just to make a log entry.
The way it is now is just historical, but it is not good - it is not loggers job to terminate your program. Deprecate/remove it.
If you really want to have a fatal call which throws, call it Fatal()
or FATAL
macro, which would internally first call LOG
, and then throw.
Yeah, I agree. But would this be a huge breaking change? Many programs would not be terminated in the emergency, which could cause lots of segmentation fault.
I did a quick test with LOG(fatal)
at (https://github.com/FairRootGroup/FairRoot/blob/dev/examples/MQ/serialization/data_generator/dataGenerator.cxx#L94) and it throws the exception as expected (which would itself lead to SIGABRT if uncaught).
Could you post a stacktrace to see a bit more detail? Also, what is the corefile filename and does it contain anything meaningful? Perhaps the failure happens there already.
I wonder why the close(stderr) is needed at all. Perhaps it is aborting because it is closed already at that point?