[fpc-devel] Misterious error

Sergei Gorelkin sergei_gorelkin at mail.ru
Sat Dec 31 15:39:59 CET 2011


31.12.2011 16:58, José Mejuto пишет:
> Hello Jonas,
>
> Wednesday, December 28, 2011, 2:43:16 PM, you wrote:
>
> JM>  The most likely problem is memory corruption by your program.
> [...]
> JM>  give more accurate diagnostics).
>
> A bit more information:
>
> Environment is win32.
>
> The line that raises the exception is in win32callback.inc 2474:
>
> -------------------------------------------
>      if (Msg=WM_CHAR) and (WParam=VK_RETURN) and
>         ((lWinControl is TCustomCombobox) or
>          ((lWinControl is TCustomEdit) and not (lWinControl is TCustomMemo ))
>         )
>      then
>        // this thing will beep, don't call defaultWindowProc
>      else
>        PLMsg^.Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
> -------------------------------------------
>
> The CallDefaultWindowProc.
>
> If I change the line to:
>
>        try
>        PLMsg^.Result := CallDefaultWindowProc(Window, Msg, WParam, LParam);
>        finally
>        end;
>
> The problem dissapears.
>
> * In the same function, if I declare an ansistring type, just the
> declare only, it works.
>
When you do either of the above, it effectively disables optimizations, forcing a ebp-based stack 
frame and putting all variables to memory. The same effect should be achievable by compiling with 
-O- or -O1 switches.

> * If the "CallDefaultWindowProc" declaration is changed to stdcall it
> also works fine.
>
Don't know what's actually changed in this case.

r19668 affects codegeneration of constructors and custom enumerators, and fixes 
http://bugs.freepascal.org/view.php?id=20827
The reported location of crash in your case is likely unrelated to the actual location of problem. 
At least, function WindowProc from win32callback.inc is not affected by r19668, as it isn't a 
constructor and doesn't involve exception handling in unmodified form.
If your code contains constructors which use interfaces, I'd suggest them as the place to look at or 
try to modify.

Regards,
Sergei



More information about the fpc-devel mailing list