DynamoRIO / DynamoRIO/dynamorio
Client static destructor not running
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
When there are two clients with a non-debug build it appears that a static destructor in the first client does not run:
```
cd dynamorio
mkdir twoclients && cd twoclients
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.7)
project(twoclients)
find_package(DynamoRIO)
if (NOT DynamoRIO_FOUND)
message(FATAL_ERROR "DynamoRIO package required to build")
endif(NOT DynamoRIO_FOUND)
add_library(client1 SHARED client1.cpp)
configure_DynamoRIO_client(client1)
add_library(client2 SHARED client2.cpp)
configure_DynamoRIO_client(client2)
EOF
cat > client1.cpp <<'EOF'
#include "dr_api.h"
#define CLIENT "client1"
class C {
public:
C() {
dr_printf("%s: constructor\n", CLIENT);
}
~C() {
dr_printf("%s: destructor\n", CLIENT);
}
};
static C global;
DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
{
dr_set_client_name(CLIENT, "");
dr_set_client_version_string("0.1.0");
dr_printf("%s: running\n", CLIENT);
}
EOF
cat > client2.cpp <<'EOF'
#include "dr_api.h"
#define CLIENT "client2"
class C {
public:
C() {
dr_printf("%s: constructor\n", CLIENT);
}
~C() {
dr_printf("%s: destructor\n", CLIENT);
}
};
static C global;
DR_EXPORT void
dr_client_main(client_id_t id, int argc, const char *argv[])
{
dr_set_client_name(CLIENT, "");
dr_set_client_version_string("0.1.0");
dr_printf("%s: running\n", CLIENT);
}
EOF
cd ../../build
mkdir build-twoclients && cd build-twoclients
cmake -DDynamoRIO_DIR=$PWD/../cmake $PWD/../../dynamorio/twoclients
make
cd ..
bin64/drrun \
-client build-twoclients/libclient1.so 0 '' \
-client build-twoclients/libclient2.so 1 '' -- echo echo
```
With a debug build I see:
```
client1: constructor
client2: constructor
client1: running
client2: running
echo
client2: destructor
client1: destructor
```
But with a non-debug build I see:
```
client1: constructor
client2: constructor
client1: running
client2: running
echo
client2: destructor
```
Contributor guide
Assessment
This issue has not been assessed yet.