DynamoRIO / DynamoRIO/dynamorio
Exit handler is not invoked for FreeCAD.exe
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
**Describe the bug**
The exit event handler is not invoked when FreeCAD.exe (the target GUI program) terminates. It terminates normally - as a result of closing the window with mouse-click.
(Sorry, I didn't know what keyword to use in the title, because this case doesn't match any keyword exactly.)
**To Reproduce**
We can use the following simple client to show the problem (compiled in the standard cmake way for DR):
```
#include
#include
void event_exit() {
FILE *f = fopen("tmp", "a");
fprintf(f, "EXIT\n");
fclose(f);
}
DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[]) {
FILE *f = fopen("tmp", "a");
fprintf(f, "MAIN\n");
fclose(f);
dr_register_exit_event(event_exit);
}
```
Run this command, wait until the end of FreeCAD initialization, then close the window (drrun and freecad processes will finish):
```
drrun.exe -c client.dll -- FreeCAD.exe
```
After that, the tmp file contains "MAIN", but does not contain "EXIT".
**Expected behavior**
The exit handler must be called.
**Versions**
DynamoRIO - version 8.0.0-1 (binary release downloaded from the official website)
OS Windows 10 - version 20H2 (build 19042.804)
This is a VirtualBox machine by Microsoft:
https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
FreeCAD 0.18.4 (x86-64) (installed by the installer from the official website)
https://www.freecadweb.org
https://github.com/FreeCAD/FreeCAD/releases/download/0.18.4/FreeCAD-0.18.4.980bf90-WIN-x64-installer.exe
**Additional context**
This problem is specific for FreeCAD; the exit handler is invoked normally for other targets (simple console programs or GUI programs, for example, Notepad).
I can see the problem even without any client - for example, using this command:
```
drrun.exe -debug -- FreeCAD.exe 1> output 2>&1
```
The output file content:
```
FreeCAD 0.18, Libs: 0.18R4 (GitTag)
В© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
##### #### ### ####
# # # # # #
# ## #### #### # # # # #
#### # # # # # # # ##### # #
# # #### #### # # # # #
# # # # # # # # # ## ## ##
# # #### #### ### # # #### ## ## ##
```
It doesn't contain phrase `` as for other applications.
Contributor guide
Assessment
This issue has not been assessed yet.