Bug #477 | gis test fails on Solaris 8 x86 | ||
---|---|---|---|
Submitted: | 22 May 2003 12:49 | Modified: | 31 May 2003 4:27 |
Reporter: | Per-Erik Martin | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 4.1 | OS: | Intel Unix with gcc. |
Assigned to: | Ramil Kalimullin | CPU Architecture: | Any |
[22 May 2003 12:49]
Per-Erik Martin
[28 May 2003 4:13]
Per-Erik Martin
Compiling the file spatial.cc with -O2 or -O3 makes the gis test fail as shown. Compiling with -O1 makes it pass. This can be a compiler bug, but it's also possible that there is some obscure bug in the function GPolygon::area() that causes the optimizer to mess up, although it's not obvious what that would be (no warnings are given, even with -Wall, in this function).
[29 May 2003 4:57]
Per-Erik Martin
This has also been repeated on RedHad Linux 7.3 using gcc 2.96, so it's not a Solarix x86 specific problem. It turns out that it's the last/innermost variables 'double y' in GPolygon::area() and GPolygon::centroid_xy() respectively that simply do not get set with higher optimization levels. This can be solved in two different ways. Either simply declare these variables as "volatile", or redefining the doubleget macro to use a temporary variable (which is the proposed fix). Hypothesis about the cause of this problem: The use of a union for the unpacking is actually a non-portable trick (although it's common practice). It's only correct to read the same part of a union that was last set. Setting one part and reading the other is strictly speaking undefined. My guess is that the optimizer throws away the assignment since it doesn't se a reference to the same part later. (It's also possible that the fact that it's done with a on-the-fly-cast is part of the problem.) Why only these two functions and only one variable in each? Probably because it's a combination of the use of doubleget and a fairly large number of double variables (> 5). Maybe in only happens to variables that doesn't fit into a register for instance (thus a significant gain if not doing the assignment at all). (But, it might still be an obscure compiler bug...)
[31 May 2003 4:27]
Michael Widenius
Thank you for your bug report. This issue has been fixed in the latest development tree for that product. You can find more information about accessing our development trees at http://www.mysql.com/doc/en/Installing_source_tree.html This will be fixed in the 4.1.1 release (Will push to 4.1 tree during weekend)