First a none debugger hint
function TCarbonControlWithEdit.SetText(const S: String): Boolean;
"const S: string" (can be dangerous, but may be harmless...>)
Look up the fpc doc. This prevents internal ref counting.
There is one case in which this can backfire (because you may without knowing it, break the documented requirements).
IF, and ONLY IF (which I do not know), this code can trigger an event, and IF in this event, you modify the variable that was passed to become "s", then s may be destroyed (because it has no refcount)
e.g.
SetText(GlobalVar); // or field in object
....
// In Event
GlobalVar := 'abc';
When the event returns, and the code is back in SetText, then "s" points to random memory.
-------------------
Debugging:
I dont know that code, so I cant give you specific tips
Check the thread and stack window. The error may be higher up in the stack (in the OS) but since there is no debug info, it will show this line in the editor.
Disable inlining, when compiling, recompile the IDE and LCL with -O-1
Set a breakpoint, soit will stop before the exception. That means you can see the data, before it happens.
If it is hin a lot, then either:
- use none stopping breakpoints and history snapshots
- find an outer stackframe, and use a 2nd breakpoint to enable the inner one
See breakpointproperties and debug-window history
you get there with F1:
http://wiki.lazarus.freepascal.org/IDE_Window:_Break_Points#Breakpoint_properties