Quantcast
Channel: Active questions tagged zeromq - Stack Overflow
Viewing all articles
Browse latest Browse all 193

ZeroMQ context singleton, provided in a DLL, crashes when program exits (VS2010 win7 x64 zmq 4.0x)

$
0
0

This is the singleton

#pragma onceclass ContextManager {public:    static ContextManager& Instance() {        static ContextManager instance;        return instance;    }    zmq::context_t& GetContext() { return ctx_;}private:    zmq::context_t ctx_;    ~ContextManager() {}};

I have a DLL with some useful Network utilities, built on ZeroMQ and using this singleton for not having to pass context around.

I link this DLL to an EXE which runs a test-suite. This test suite works, sending and receiving some messages. When the program exits, the ContextManager destructor crashes saying "Assertion failed: Successful WSASTARTUP not yet performed (......\src\signaler.cpp:137)"

More details:

  • The application is single-threaded.
  • If I just call the Instance.GetContext() method from the .EXE and return (no test running, no more calls to the DLL interface), then it fails too.
  • If I define this singleton before the main (thus, inside the exe without using the object from the DLL) then it works.
  • WSastartup is called just once and it works.

I do not want to expose any implementation details to the DLL clients, so I would like to have this singleton inside the DLL. How could achieve this?


Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>