[lazarus] The timer issue (win32)

Vincent Snijders VSDS at RND.VB.CBS.NL
Thu Jun 26 03:39:39 EDT 2003



> > Good you found this bug. I have been looking at it before, but was
> > always puzzled, why simple adding a writeln could change the crashing
> > behaviour.
> >
> > I thought that stdcall was the default calling convention in fpc.
> > Is this not true?
> 
> No. FPC uses standard a stack-push strategy, pushing parameters from right
> to left, callee clears the stack.
> 
> stdcall convention is the usual convention for windows DLL functions and
> windows callbacks.
> 
> It is all documented in the programmer's manual.
> Michael.

I looked it up in the programmers manual:
http://www.freepascal.org/docs-html/prog/progse19.html#x115-1120006.3

Modifier  Pushing order Stack cleaned by alignment  registers saved 

¡none¿  Right-to-left  Function  default  None  
pascal  Left-to-right  Function  default  None  
safecall  Right-to-left  Function  default  GCC registers 
stdcall  Right-to-left  Function  GCC alignment GCC registers 

At first I didn't see any critical differences between none and stdcall.
None also uses a stack-push strategy, pushing parameters from right
to left, callee clears the stack. But the difference seems to be that the callback procedure must keep the GCC-registers (ESI, EDI, EBX) unmodified.
That explains, why an empty callback function had no problems, but when you added some statements, it crashed.

Vincent 






More information about the Lazarus mailing list