This code, compiles with g++ using -std=c++11. Linking with g++, when libunwind is linked in statically program crashes after catching in exerciseBug (after rethrow). LDFLAGS that result in crash:
-Wl,-Bstatic -lunwind -Wl,-Bdynamic -llzma
when libunwind is linked in dynamically, code works as normally. LDFLAGS that result in normal operation:
-Wl,-Bstatic -Wl,-Bdynamic -lunwind -llzma
#include <iostream>
using namespace std;
void exerciseBug()
{
try {
throw exception();
} catch (exception &err) {
cerr << "caught in exerciseBug\n";
throw;
}
}
int main()
{
try {
exerciseBug();
} catch (exception &err) {
cerr << "caught in main\n";
::exit(0);
}
}
Question is why is does libunwind need to be dynamically linked in? (Running on Ubuntu 16.04; g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609)