1 | | Scenario: a DLL register an exit list function using atexit() and the dll is loaded using DosLoadModule; when the executable calls DosFreeModule, the exit list handler is not executed nor removed from the list of callbacks. |
2 | | When the executable terminates, it tries to call the dll exit callback and a crash occurs since the dll code is already unloaded from memory. |
3 | | |
4 | | This doesn't happen when the dll is linked at compile time. |
5 | | |
6 | | Testcase attached. |
| 1 | Use {{{atexit()/on_exit()}}} to register a callback residing in a dynamically loaded DLL. Then unload the DLL. When {{{exit()}}} eventually is called, the application crashes because the callback code isn't there anylonger. |