Opened 11 years ago

Closed 9 years ago

#5256 closed defect (fixed)

[PATCH] Divison by 0 in mitab_mapindexblock.cpp. Fails on 64 bit

Reported by: maxim Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords: mitab
Cc: Daniel Morissette

Description (last modified by maxim)

Under certain conditions a division by 0 occurs in TABMAPIndexBlock::PickSeedsForSplit method. When the code runs as part of mitab.dll on 32 bit system the division by 0 is silently ignored resulting in dX or dY == -1.#IND. Inside a 64 bit process a floating point exception is raised. I've created a fix for this problem.

After some more research on this problem, the problem is not directly related to 32/64 bit. The original setup where this problem was observed was a Delphi executable calling a .NET assembly method which in turn called methods in MITAB.dll. It seems that some of the libraries/frameworks involved in this change FPU status word differently in 32 and 64 bit processes.

I was able to create a test case for this problem by modifying tab2tab utility and running it on a attached mif file. Modifications in tab2tab are related to changing the FPU control word in such a way that divisions by zero cause exceptions. The change was tested on 32 bit version of tab2tab compiled with Visual c++ 2010.

Attachments (5)

mitab_mapindexblock.cpp (57.6 KB ) - added by maxim 11 years ago.
Division by 0 fix
ticket5256.patch (508 bytes ) - added by Even Rouault 11 years ago.
Patch generated from attached .cpp
tab2tab.cpp (11.2 KB ) - added by maxim 11 years ago.
tab2tab with division by zero exception enabled
points.mid (1.5 KB ) - added by maxim 11 years ago.
test dataset
points.mif (4.2 KB ) - added by maxim 11 years ago.
test dataset

Download all attachments as: .zip

Change History (10)

by maxim, 11 years ago

Attachment: mitab_mapindexblock.cpp added

Division by 0 fix

comment:1 by Even Rouault, 11 years ago

Cc: Daniel Morissette added
Keywords: mitab added
Summary: Divison by 0 in mitab_mapindexblock.cpp. Fails on 64 bit[PATCH] Divison by 0 in mitab_mapindexblock.cpp. Fails on 64 bit

It would be good if you could provide a test case (sample file + command used) where this issue was triggered.

by Even Rouault, 11 years ago

Attachment: ticket5256.patch added

Patch generated from attached .cpp

comment:2 by maxim, 11 years ago

Description: modified (diff)

by maxim, 11 years ago

Attachment: tab2tab.cpp added

tab2tab with division by zero exception enabled

by maxim, 11 years ago

Attachment: points.mid added

test dataset

by maxim, 11 years ago

Attachment: points.mif added

test dataset

comment:3 by Even Rouault, 9 years ago

I've applied the fix although I couldn't reproduce the issue with the provided data (it doesn't even go in the function patched)

trunk r28261 "MITAB: fix potential floating point exception in TABMAPIndexBlock::PickSeedsForSplit() (#5256)"

comment:4 by Jukka Rahkonen, 9 years ago

It would be great if maxim could verify if the fix is good. Otherwise I try to remember to close the ticket as fixed within couple of weeks anyway.

comment:5 by Even Rouault, 9 years ago

Resolution: fixed
Status: newclosed

Batch closing of MITAB tickets fixed in GDAL. They were kept open because not merged into MITAB separate repository, but the latter one is inactive, so let's close them definitely.

Note: See TracTickets for help on using tickets.