[fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

Den Jean Den.Jean at telenet.be
Tue Mar 7 06:54:18 CET 2006


Hi,

I have a strange problem. My Qt4 demo program worked 
fine with FPC 2.0.0, but crashes (div by zero) with FPC 2.0.2.
Debugging shows that indeed a div by zero is done within
the Qt4 lib. However with FPC 2.0.0 or using C++ code the library
isn't bothered with the div by zero. When I use FPC 2.0.2 however
it is.

I added some writelns euh printfs in the Qt lib:
 if (p1.x() == p2.x()) printf("Before DIV by Zero: p1.x:%f p2.x:
%f\n",p1.x(),p2.x());
edge.m = (p1.y() - p2.y()) / (p1.x() - p2.x()); // this causes the div by zero
if (p1.x() == p2.x()) printf("After DIV by Zero: p1.x:%f p2.x:
%f\n",p1.x(),p2.x());

with FPC 2.0.2 I get

Before DIV by Zero: p1.x:196.500000 p2.x:196.500000
An unhandled exception occurred at $405CB772 :
EDivByZero : Division by zero
  $405CB772
etc

with FPC 2.0.0 or the original C++ demo program I get:
Before DIV by Zero: p1.x:196.500000 p2.x:196.500000
After DIV by Zero: p1.x:196.500000 p2.x:196.500000
Before DIV by Zero: p1.x:187.500000 p2.x:187.500000
After DIV by Zero: p1.x:187.500000 p2.x:187.500000
Before DIV by Zero: p1.x:100.000000 p2.x:100.000000
After DIV by Zero: p1.x:100.000000 p2.x:100.000000
and so on, never a crash (but why :-)

Anyone any idea?

I uploaded everything to 
(Qt libs, demo src code)
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/demo_shapedclock_0.6.tar.gz

I compiled Qt 4.1.1 with debug info (hence the size of the tar)
the file I added the printfs was
qt-x11-opensource-src-4.1.1/src/gui/painting/qpaintengine_x11.cpp

compile:
export LD_LIBRARTY_PATH=.
ppc386 -gl  shapedclock.pas
./shapedclock

The program should look like this:
http://users.pandora.be/Jan.Van.hijfte/qtforfpc/shapedclock.png

Here is some gdb output
...
Qt: gdb: -nograb added to command-line options.
         Use the -dograb option to enforce grabbing.
Before DIV by Zero: p1.x:196.500000 p2.x:196.500000

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 1087534720 (LWP 10897)]
0x405cb772 in qt_tesselate_polygon (traps=0xbf812e40, pg=0x8135b50, pgSize=9, 
winding=true)
    at painting/qpaintengine_x11.cpp:361
361             edge.m = (p1.y() - p2.y()) / (p1.x() - p2.x()); // line 
derivative
Current language:  auto; currently c++
(gdb) bt
#0  0x405cb772 in qt_tesselate_polygon (traps=0xbf812e40, pg=0x8135b50, 
pgSize=9, winding=true)
    at painting/qpaintengine_x11.cpp:361
#1  0x405cca91 in QX11PaintEnginePrivate::fillPolygon_dev (this=0x81351e0, 
polygonPoints=0x81367c8,
    pointCount=9, gcMode=QX11PaintEnginePrivate::PenGC, 
mode=QPaintEngine::WindingMode)
    at painting/qpaintengine_x11.cpp:1533
#2  0x405cd050 in QX11PaintEnginePrivate::fillPath (this=0x81351e0, 
path=@0xbf812fb0,
    gc_mode=QX11PaintEnginePrivate::PenGC, transform=false) at 
painting/qpaintengine_x11.cpp:1648
#3  0x405cd914 in QX11PaintEngine::drawPath (this=0x81309b8, path=@0xbf8130f4)
    at painting/qpaintengine_x11.cpp:1688
#4  0x405c41db in QX11PaintEngine::drawLines (this=0x81309b8, 
lines=0xbf8132cc, lineCount=1)
    at painting/qpaintengine_x11.cpp:907
#5  0x4058285d in QPainter::drawLines (this=0x812e250, lines=0xbf8132cc, 
lineCount=1)
    at painting/qpainter.cpp:3243
#6  0x400b7eef in QPainter::drawLine () from ./libqt4intf.so
#7  0x4008f801 in QPainter_drawLine3 () from ./libqt4intf.so
#8  0x080497cf in TCLOCK__PAINT (E=0xbf813848, this=0x812929c) at 
shapedclock.pas:164



kind regards,

Den Jean




More information about the fpc-devel mailing list