Bug 298502

Summary: infinite loop in MercatorProjection.cpp
Product: [Applications] marble Reporter: Sune Vuorela <debian>
Component: generalAssignee: marble-bugs
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: 1.4 (KDE 4.9)   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Sune Vuorela 2012-04-20 19:16:39 UTC
in a custom app built on libmarble, I've hit a infiinte loop in MercatorProjection.cpp

Reproducible: Sometimes

Steps to Reproduce:
build a my secret app and run it
Actual Results:  
infinite loop in ~75% of the cases

Expected Results:  
no infinite loop

in MercatorProjection.cpp in the function
231 bool MercatorProjection::geoCoordinates( const int x, const int y,                                                                                                                                                                                       

236     const int radius = viewport->radius(); // can be null in our case

244     const qreal pixel2Rad = M_PI / (2 * radius); // pixel2Rad is now infinity

249         lon = xPixels * pixel2Rad + centerLon; // lon is now infinity

251         while ( lon > M_PI )  lon -= 2*M_PI; // inf-=2*M_PI is still inf and > M_PI

loops forever there.

line numbers is based on current HEAD which is v4.7.95-484-ga4626c0

bug observed with marble 4.7.4 but code looks still the same
Comment 1 Dennis Nienhüser 2012-05-17 11:38:28 UTC
Git commit 6e0eaeb455a1d52ec413587cb277acd6214706c6 by Dennis Nienhüser.
Committed on 17/05/2012 at 13:36.
Pushed by nienhueser into branch 'master'.

Require positive radii, ignore other.

M  +1    -0    src/lib/Projections/MercatorProjection.cpp
M  +5    -3    src/lib/ViewportParams.cpp
M  +6    -1    src/lib/ViewportParams.h
M  +11   -0    tests/MercatorProjectionTest.cpp
M  +8    -0    tests/ProjectionTest.cpp

http://commits.kde.org/marble/6e0eaeb455a1d52ec413587cb277acd6214706c6