In addition to René´s valuable advice:
Running with /pbdebug takes a very long time to get to test the point where your application crashes, but ...
Roland Smith has invented this nice little way of being able to activate /pbdebug at runtime at any point of running your code: https://www.topwizprogramming.com/freecode_pbdebug.html
I haven't used it myself, but it seems pretty straight forward.
---------------------------------------------------------------------------
In the n_pbdebug object, local external function declarations, replace pbvm105.dll with pbvm190.dll:
Function long rt_dbg_on() &
Library "pbvm105.dll"
Function long rt_dbg_off() &
Library "pbvm105.dll"
Function long rt_dbg_set(long option) &
Library "pbvm105.dll"
Function long rt_dbg_del(long option) &
Library "pbvm105.dll"
Function long rt_dbg_outfile(string filename) &
Library "pbvm105.dll"