Closed stefantalpalaru closed 3 months ago
The fix is to call any backtrace function early in your program execution. Once you've done that, libbacktrace shouldn't need to open any more files. You can just discard the results.
The fix is to call any backtrace function early in your program execution.
My use case was generating stack traces for exceptions in Nim programs: https://github.com/nim-lang/Nim/pull/12922
OK, but I'm not sure what you are saying. I think that my comment still applies.
I think that my comment still applies.
No, of course not. With exceptions, I collect program counters during stack traversal and use them to generate a stack trace (using libbacktrace) when printing an exception: https://github.com/status-im/nim-libbacktrace/blob/master/libbacktrace.nim
That usually happens at the end of a program, for fatal errors, or in the middle of it, for recoverable ones where we want to log exceptions (and associated stack traces).
I think that we are somehow failing to communicate.
In the original issue report you said "What we need is to replace that on-demand file opening with an early one - either by making fileline_initialize() public, so we can call it after backtrace_create_state(), or by including a call to it in the latter function."
I am saying that such a function already exists: call backtrace_full
and ignore the results.
Got it. Thanks.
When you reach your process' open file descriptor limit, you can no longer produce a backtrace, because libbacktrace tries and fails to open the executable:
What we need is to replace that on-demand file opening with an early one - either by making
fileline_initialize()
public, so we can call it afterbacktrace_create_state()
, or by including a call to it in the latter function.