TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Using C++23 <stacktrace> to get proper crash logs in C++ programs

103 点作者 TylerGlaiel将近 2 年前

10 条评论

rightbyte将近 2 年前
This is my favorite macro: &quot;#define WIN32_LEAN_AND_MEAN&quot;<p>Why is it that even though Github or what ever has cutsie unicorns (or whatever it is) as error messages it feels fake and contrived while this define just feels like some random dude at MS naming it before going off to write Solitaire?
评论 #36578151 未加载
评论 #36578775 未加载
评论 #36578186 未加载
评论 #36579481 未加载
评论 #36582588 未加载
评论 #36578158 未加载
PaulDavisThe1st将近 2 年前
If you don&#x27;t care about exotica like async or signal safety, and just need to see the callstack from arbitray points, this can do the job without C++23:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Ardour&#x2F;ardour&#x2F;blob&#x2F;master&#x2F;libs&#x2F;pbd&#x2F;stacktrace.cc">https:&#x2F;&#x2F;github.com&#x2F;Ardour&#x2F;ardour&#x2F;blob&#x2F;master&#x2F;libs&#x2F;pbd&#x2F;stackt...</a><p>(2 different implementations, one for POSIX-y systems with the execinfo.h header, and one for Windows)<p>The demange() function is elsewhere.
评论 #36582505 未加载
zX41ZdbW将近 2 年前
There are parts of C++ standard library that no one should ever use.<p>The examples are: regex, iostreams, locale...<p>My main concern - this can also become such a dead weight.
评论 #36578759 未加载
评论 #36578754 未加载
evmar将近 2 年前
The code:<p><pre><code> &#x2F;&#x2F;a decent amount of this was copied&#x2F;modified from backward.cpp (https:&#x2F;&#x2F;github.com&#x2F;bombela&#x2F;backward-cpp) </code></pre> The license on the other side of that link:<p><pre><code> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</code></pre>
评论 #36582019 未加载
评论 #36579503 未加载
catiopatio将近 2 年前
Reliable in-process crash reporting is exceptionally difficult.<p>The code must be fully async-safe, which means you cannot use &lt;stacktrace&gt;. You also cannot acquire mutexes, use any of the standard allocators, etc etc etc.
评论 #36578642 未加载
评论 #36578944 未加载
评论 #36578094 未加载
elsamuko将近 2 年前
A question: Would it be possible to pass the stacktrace of the current thread to another, so that the stacktrace would be traceable across threadpools or worker threads?
评论 #36578649 未加载
r2vcap将近 2 年前
Yet another library feature that will be used by nobody... While having a standard library is good, system programming presents tricky aspects like async-safety that are not adequately addressed. Therefore, considering the challenges involved, I believe it would be better to utilize existing libraries like crashpad to handle such scenarios.
评论 #36584171 未加载
mlhpdx将近 2 年前
I may be wrong, but as I recall it is good form to chain exception filter calls by making note of the return from `SetUnhandledExceptionFilter`. For example, if I want to use `&lt;stacktrace&gt;` and do copy-on-write using memory protection in the same program.
koyote将近 2 年前
Maybe I am doing something wrong but the example code does not seem to work on VS 2022 (no output file after a div by zero or stack overflow crash).
anarazel将近 2 年前
This does not even remotely look to be signal safe to me?
评论 #36582611 未加载