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

Breaking at a throw statement #2477

Closed
DavidPfander-UniStuttgart opened this issue Feb 2, 2017 · 7 comments
Closed

Breaking at a throw statement #2477

DavidPfander-UniStuttgart opened this issue Feb 2, 2017 · 7 comments

Comments

@DavidPfander-UniStuttgart
Copy link

DavidPfander-UniStuttgart commented Feb 2, 2017

It seems that I can't get a meaningful stack trace for my hpx application, even in the case of a trivial throw. I constructed a minimal example that throws a string:

#include <iostream>

#include <hpx/hpx_init.hpp>
#include <hpx/hpx_start.hpp>
#include <hpx/include/iostreams.hpp>

int hpx_main(int argc, char *argv[]) {
		throw "fdjfiosjd";
		return hpx::finalize();
}

int main(int argc, char **argv) {
    // throw "fdisjfodis";
		hpx::start(argc, argv);
		hpx::stop();
    return 0;
}

and compiled it with

g++ -o unhandled_exception.o -c -std=c++14 -O0 -ffast-math -mavx2 -mfma -g -DHPX_DEBUG -DHPX_APPLICATION_EXPORTS -DHPX_ENABLE_ASSERT_HANDLER -I/home/pfandedd/hpx_install_debug/include -I/home/pfandedd/hpx_install_debug/include/hpx/external -I/home/pfandedd/Vc_install_debug/include -I/home/pfandedd/boost_1_62_0_install_debug/include unhandled_exception.cpp

When I now $ gdb unhandled_exception, (gdb) catch throw and (gdb) run I get the stacktrace found in stacktrace.txt. As you can see, it didn't break where it should have breaked.

On the other hand, the non-hpx program

#include <iostream>

int main(int argc, char **argv) {
    throw "fdisjfodis";
    std::cout << "hallo" << std::endl;
    return 0;
}

compiled with g++ -g -O0 trivial.cpp gdb breaks at the expected line with the throw statement.

How can I get a catch throw to break at the expected line with an hpx application?

@DavidPfander-UniStuttgart DavidPfander-UniStuttgart changed the title Catching an exception within an hpx thread Breaking at a throw statement Feb 2, 2017
@hkaiser hkaiser added this to the 1.0.0 milestone Feb 2, 2017
@hkaiser
Copy link
Member

hkaiser commented Feb 2, 2017

The exception you're seeing is one thrown by HPX during startup for unrelated reasons. Either simply continue in gdb until you hit your exception, or - in this case - alternatively delete the component binary libhpx_sine_component.so.

Note to self: I need to finally make sure that the sine component will be loaded by the sine-performance-counter example only.

@DavidPfander-UniStuttgart
Copy link
Author

DavidPfander-UniStuttgart commented Feb 2, 2017

I checked every break up to program termination, and I couldn't find my line number. (It's a lot of output, hard to be sure that it isn't there.)

Additionally, how do I not build that component?

@DavidPfander-UniStuttgart
Copy link
Author

Update: ok, just deleted libhpx_sine*, that helped.

With only one break and a much shorter stacktrace, I also found the correct throw statement in the stacktrace.

@sithhell
Copy link
Member

sithhell commented Feb 2, 2017

don't do "make all" or "make install", or disable the examples (-DHPX_WITH_EXAMPLES=Off).

@hkaiser
Copy link
Member

hkaiser commented Feb 2, 2017

See #2478, this should solve the issue.

@hkaiser
Copy link
Member

hkaiser commented Feb 5, 2017

#2478 has been merged, can we close this now?

@DavidPfander-UniStuttgart
Copy link
Author

Thanks for the fix!

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

No branches or pull requests

3 participants