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

Problem calling load_here() in a parent constructor #317

Open
craigsoules opened this issue Oct 13, 2023 · 0 comments
Open

Problem calling load_here() in a parent constructor #317

craigsoules opened this issue Oct 13, 2023 · 0 comments

Comments

@craigsoules
Copy link

We are trying to capture a backtrace in a parent class constructor, but it is failing to do so. The code looks like this:

class Error() {
private:                                                                                                                                                                                                       
    backward::StackTrace _trace;
public:
    Error() { _trace.load_here() }

    void print_trace() {
        backward::Printer printer;                                                                                                                                                                             
        printer.print(_trace);   
    }
}

class MyError() {
public:
    MyError() { }
}

void error() {
    throw MyError();
}

int main(int argc, char *argv[]) {
    try {
        error();
   } catch(Error &e) {
       e.print_trace();
   }
}

In the version of backward from vcpkg there is actually a bug where the call to details::unwind returns -1 causing a vector sizing exception to be thrown, which it looks like has been fixed, however, I'm unclear why it can't do the unwinding properly in this case.

Is there something special about parent constructors that causes unwind to fail to work properly? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant