How to debug a crash that only occurs on application shutdown? (Delphi)

后端 未结 6 2362
一生所求
一生所求 2021-02-13 06:21

So, after some recent changes we discovered that one of our oldest applications is sometimes crashing on shutdown. This manifests itself either in the form of \"Runtime error 21

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 07:13

    A runtime error 216 means that you have an Av (access violation) and SysUtils has already stopped translating those errors to exceptions.

    First try: Build with debug DCU's and look in the unit system where the error is raised, set a breakpoint there. hopefully you can catch it in the debugger and work from there.

    You probably have a memory bug (dangling pointer, null reference etc etc use of s string constant in an already finalized unit) and the best trick is to check the finalizations after sysutils is finalized. You can do this by building WITH debug dcu's, setting the break point to the finalization in sysutils and start stepping through the code until the error occurs.

提交回复
热议问题