pr-2178/derrickstolee/trace2-dont-die-v2
tagged this
25 Aug 18:56
After v1 was posted, based on a concrete example of tracing leading to a recursive die() problem, more evidence has come up to imply that allocations are failing for some users more often. This is potentially an issue with the allocator chosen by Git for Windows, which is being discussed elsewhere. But the conclusion is this: the trace2 API shouldn't call helpers that might call die(). It's too low-level for that. In this v2, I have a much more robust approach to removing die() from the trace2 API. This starts with a new banned-die.h header file at the root of the repo and including it from all trace2 API *.c files. It starts empty, but the later patches will add one method at a time: * xsnprintf() : This is the original patch, but made more complete by adding the method to banned-die.h. * xstrdup() * ALLOC_ARRAY() * xstrfmt() * ALLOC_GROW() * xcalloc() During each patch, the goal was to have the trace2 logic be "as correct as possible" when an allocation failure occurs. This may mean that we have incomplete messages or dropped trace messages. The focus here is that the trace2 API should never cause a process-ending failure, because those failures will trigger trace2 API calls while reporting the failure. Thanks, -Stolee Derrick Stolee (7): banned-die: create header for banning of functions trace2: tolerate failed timestamp formatting trace2: remove use of xstrdup() trace2: remove use of ALLOC_ARRAY() trace2: remove use of xstrfmt() trace2: remove use of ALLOC_GROW() trace2: remove use of xcalloc() banned-die.h | 32 +++++++++++++++++ trace2.c | 51 ++++++++++++++++++++++++--- trace2/tr2_cfg.c | 1 + trace2/tr2_cmd_name.c | 1 + trace2/tr2_ctr.c | 11 +++++- trace2/tr2_dst.c | 1 + trace2/tr2_sid.c | 1 + trace2/tr2_sysenv.c | 7 ++-- trace2/tr2_tbuf.c | 50 +++++++++++++++++++-------- trace2/tr2_tgt_event.c | 1 + trace2/tr2_tgt_normal.c | 1 + trace2/tr2_tgt_perf.c | 1 + trace2/tr2_tls.c | 76 +++++++++++++++++++++++++++++++++++++++-- trace2/tr2_tls.h | 7 ++++ trace2/tr2_tmr.c | 15 ++++++-- 15 files changed, 229 insertions(+), 27 deletions(-) create mode 100644 banned-die.h base-commit: e9019fcafe0040228b8631c30f97ae1adb61bcdc Submitted-As: https://lore.kernel.org/git/pull.2178.v2.git.1787684181.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2178.git.1784131932489.gitgitgadget@gmail.com