Hi,
I have thoughts on this :
Ich habe die Optimierung ausgeschaltet und dann funktioniert es.
You should hunt for uninitialized variables or records fields.
So :
1) If there is warnings then
handle them all, make sure they are not silenced too for some units with compiler directives.
2) Delphi compiler generate different code for optimized and non-optimized, but one thing is always there, is the heavy usage of the stack, some times the compiler does good job and skip the stack variables storage for every variable, but one thing is sure, with no optimization it always have a copy on the stack of all local variables including record and most likely will save the parameter to the local function/procedure to the stack too, this will leads to expanded stack with no optimization and shorter stack and more condensed with optimization, so in theory without optimization the stack grow further and more likely to land on zero filled stack, and with optimization it more likely will land on already used stack position (aka dirty stack !), in other words, uninitialized variable in a hidden way or non-direct way was zeroed and worked as initialized when the optimization was disabled, look for those, remember this, if you have filled a field in a locally declared record the compiler will not warn about other fields, and will see it as initialized, so a record on the stack easily can produce your problem.
3) Try to enable optimize per
unit with compiler directive (adding it on top of the
unit file), it might/could narrow your search, though this is tedious, yet it is faster than reviewing all the code, procedure by procedure and line by line.
Hope that help and good luck.