Most likely it is your GTK+ theme. Many GTK+ themes and theme engines abuse
floating point calculations which go unnoticed normally since the vast
majority of C/C++ programs do not check for them. The solution is to do
something like (IIRC):

SetExceptionMask([]);


Which disables all floating point exceptions. Alternatively switch to a
theme that doesn't mess FP calculations, bu you can't guarantee that your
users will have it.


On Thu, Mar 7, 2013 at 10:04 AM, Xiangrong Fang <xrf...@gmail.com> wrote:

> 2013/3/7 leledumbo <leledumbo_c...@yahoo.co.id>
>
>
>> Because setting the mask means telling the processor to generate (or not
>> to
>> generate? I forgot) SIGFPE for the given operations. e.g. exZeroDivide may
>> trigger SIGFPE if there's a division by zero with floating point
>> operation.
>> How to trace? You already get it, the program will report the line that
>> causes it, you can directly go to the respective line to see what happens.
>> But this requires that the code lies in the program space (not in external
>> library) and the code is compiled with runtime error backtrace (-gl).
>> Otherwise, the program can only report as deep as it can find.
>>
>
> I don't understand:
>
> 1) even if I set the masks, why an empty LCL application generate SIGFPE?
> It means that somewhere GTK or whatever library *indeed* do things like
> 1/0, only that they are normally hidden/not reported?
>
> 2) I already found the problem in my code which is a like look like:
>
> *if tbLog.Down then Y := exp(Y);*
>
> And Y is a big number e.g. 2500, which caused floating point overflow.
> The problem was that the number itself should be Log()ed, so that exp()
> only restore its original value.   That was my bug, but the weird thing is
> that SIGFPE is generated in unit LCLType on the line that set font height,
> which is very innocent, and after I commented out the font.Height
> operation, the SIGFPE slipped to somewhere else, but NEVER on the line that
> generated it!
>
> Could you explain why? and how to locate where the SIGFPE occurred?
>
> Thanks!
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to