Crash when callback is disconnected in a dll
- Dominant language
- C++
- Stars
- 89
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
When using signals2 across multiple DDLs, everything works fine until the dlls gets unloaded, which results in crash the next time we dispatch the signal.
I found this [stackoverflow post](https://stackoverflow.com/questions/28703432/access-violation-when-using-boostsignals2-and-unloading-dlls) which describes the same issue i'm having.
The test sample:
Shared.cpp:
```CPP
#include
#include
#include
struct SomeInterface
{
boost::signals2::signal signal;
};
boost::signals2::connection con;
void init(SomeInterface* iface)
{
con = iface->signal.connect([] { std::cout << "Hello, Shared!" << std::endl; });
}
void shutdown()
{
con.disconnect();
}
BOOST_DLL_AUTO_ALIAS(init);
BOOST_DLL_AUTO_ALIAS(shutdown);
```
Host.cpp:
```CPP
#include
#include
#include
struct SomeInterface
{
boost::signals2::signal signal;
};
int main()
{
SomeInterface* iface = new SomeInterface;
{
boost::dll::shared_library dll("Shared", boost::dll::load_mode::append_decorations);
auto init = dll.get("init");
auto shutdown = dll.get("shutdown");
init(iface);
iface->signal();
shutdown();
}
iface->signal();
return 0;
}
````
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.