Most of the answer was already given.
1) Make sure you are setup for debugging
https://wiki.lazarus.freepascal.org/Debugger_SetupThe global part should be correct out of the box.
But make sure in your project settings, that debug info is enabled.
2) Run your app (using "Run" / do not use "run without debugger")
3) When the problem happens, use the Pause button (or "Pause" from the run menu)
Ignore the assembler / you can close that
4) Open "Callstack" and "Threads" from menu "View" > "Debug Windows"
On Windows you will have to change the thread, on other platforms it may already be correct but you may have to check.
When going through the threads, watch the callstack.
For one of the threads (using the "current" button to select it), the callstack should show many lines, and within the top 10 lines it should show one of your source files.
Then select your source file in the callstack (if it is not the very top entry). (Use "Current" from the popup up menu of the callstack)
Double click the callstack to see the source.
Now you can either
- if your source is at the top of the callstack => singlestep
Otherwise
- set a breakpoint on the next source line, and run => will pause at breakpoint, then you can single step
- Use "Step out" to get to your source file (may need several step outs)
After you have set the callstack with "current" you can also inspect variables (hover mouse or "add to watches")