This can happen when you are calling the realize function,
with arrays that were initialized in another function call.
For example:
void createWindow(DB window) {
string options[] = {"Option1", "Option2"};
verticalRadioBox(window, "Options:", options, 0);
}
DB window = create("Test", styleFixed);
createWindow(window);
realize window; // realize with invalid array
show window;
An array is created in the createWindow(DB) function.
By the time realize() is called, the createWindow(DB) is exited,
and the array is not valid anymore (it's a local variable).
This code runs correctly because no additional function is called between createWindow(DB) and realize() .
But the debugger will fail, precisely because it will insert additional function calls under the hood,
as stated in the debugger architecture,
and thus will reveal this code weakness.
The workaround is either:
- to put the
realize() call at the end of the createWindow(DB) function,
- or to make the array variable a global variable, that will remain valid by the time
realize() is called.
|