Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alternative signal handler stack should last #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,9 @@ class Printer {

#if defined(BACKWARD_SYSTEM_LINUX) || defined(BACKWARD_SYSTEM_DARWIN)

const size_t stack_size = 8 * 1024 * 1024;
static char *alt_stack = static_cast<char *>(malloc(stack_size));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but... this allocates RAM out of the control of the user. The intend of the SignalHandling class is to be used only if you want it. If you don't you shouldn't be paying anything for it.


class SignalHandling {
public:
static std::vector<int> make_default_signals() {
Expand Down Expand Up @@ -3876,12 +3879,10 @@ class SignalHandling {
: _loaded(false) {
bool success = true;

const size_t stack_size = 1024 * 1024 * 8;
_stack_content.reset(static_cast<char *>(malloc(stack_size)));
if (_stack_content) {
if (alt_stack) {
stack_t ss;
ss.ss_sp = _stack_content.get();
ss.ss_size = stack_size;
ss.ss_sp = alt_stack;
ss.ss_size = alt_stack;
ss.ss_flags = 0;
if (sigaltstack(&ss, nullptr) < 0) {
success = false;
Expand Down Expand Up @@ -3961,7 +3962,6 @@ class SignalHandling {
}

private:
details::handle<char *> _stack_content;
bool _loaded;

#ifdef __GNUC__
Expand Down