onnxruntime
73b0fc6c - Include originating function in C-API catch-all exception message (#29561)

Commit
7 days ago
Include originating function in C-API catch-all exception message (#29561) ### Description <!-- Describe your changes. --> Include the originating function name in the C-API catch-all diagnostic without introducing throwing string allocations: - Route the catch-all through a single out-of-line `noexcept` helper. - Format into a bounded 256-byte stack buffer and pass its known bounded length to the internal status constructor. - Share status allocation/copying with public `CreateStatus`, preserving its message cap and allocation-failure behavior. - Avoid the GCC warning caused by rescanning that buffer with the public factory's 4096-byte `strnlen` bound. - Add regression tests for function context, truncation, nonstandard exceptions, null/empty messages, and the public message limit. - Keep the no-exceptions macro path unchanged. Lambda sites may identify the function as `operator()`. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> The earlier `MakeString` implementation could terminate during diagnostic formatting inside `noexcept`. Bounded, allocation-free formatting removes that risk without expanding stream construction at every catch-all site. The GCC follow-up fixes the reported warning rather than suppressing it. ### Validation - Fresh Windows Release CPU/DirectML build and `.\onnxruntime_test_all.exe --gtest_filter="ErrorCodeTest.*"`: 5 passed after the GCC fix. - Earlier native allocator-failure harness reproduced termination in the previous allocating handler and verified the allocation-free handler survived failing C++ allocations. - Earlier no-exceptions compilation passed with warnings treated as errors. - Linux/GCC14 current-head CI is required to confirm the portability correction; no local GNU environment is available. - Full minimal/mobile binary-size comparison was not run locally; applicable CI remains required. --------- Co-authored-by: Gopalakrishnan Nallasamy <gopalakrishnan.nallasamy@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Parents
Loading