Specify construction/destruction order of static locals in different accessors

后端 未结 2 1119
时光取名叫无心
时光取名叫无心 2021-01-23 05:45

I\'m experiencing a crash in cxa_finalize running a program (this is a program, and not a library within):

$ ./ac-test.exe 
Assertion failed: AcLock         


        
2条回答
  •  无人及你
    2021-01-23 06:26

    Assuming the dependency is non-cyclical, you can just leverage the standard behavior of initialization in the order of code flow entry into the function and destruction in reverse order of initialization.

    In other words, have a call to GetLogger() to initialize the logger and then GetAcceptSockets() to initialize the list. This will result in the socket list getting destructed first (while the logger still exists) and then the logger getting destructed last.

提交回复
热议问题