Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2316 closed defect (fixed)

Crash when using TMS tiles

Reported by: tom_verbeure@… Owned by: Chris Browet
Priority: major Milestone:
Component: merkaartor Version:
Keywords: Cc:

Description

Configuration: Mac, version 0.14, compiled from source QT: 4.5.1

When you specify a wrongly configured TMS server and then zoom in/zoom out to the same point (or move around the map etc), Merkaartor will crash as follows:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000004
0x034e0b80 in QCoreApplication::notifyInternal ()

> bt
#0  0x034e0b80 in QCoreApplication::notifyInternal ()
#1  0x0294a31a in qt_mac_socket_callback ()
#2  0x9709c6f0 in __CFSocketDoCallback ()
#3  0x9709dd35 in __CFSocketPerformV0 ()
#4  0x970933c5 in CFRunLoopRunSpecific ()
#5  0x97093aa8 in CFRunLoopRunInMode ()
#6  0x0294a760 in QEventDispatcherMac::processEvents ()
#7  0x034e0151 in QEventLoop::processEvents ()
#8  0x034e02fd in QEventLoop::exec ()
#9  0x034e414e in QCoreApplication::exec ()
#10 0x001ca547 in main (argc=1, argv=0xbffff03c) at Main.cpp:201

The TMS server configuration was: localhost with some bogus path parameters

The local server running was simply a freshly created rails application with no changes whatsoever that was started as ./scripts/server -p 80

Attachments (1)

patch.txt (1.7 KB) - added by tom_verbeure@… 10 years ago.
mapnetwork.cpp improvements

Download all attachments as: .zip

Change History (9)

comment:1 Changed 10 years ago by tom_verbeure@…

This crash also happens in Windows on the released 0.14 binary.

Changed 10 years ago by tom_verbeure@…

Attachment: patch.txt added

mapnetwork.cpp improvements

comment:2 Changed 10 years ago by tom_verbeure@…

I spent two full battery chargers of my laptop to track this one down, but without much success.

However, I did find a couple of things that are fishy in the current code:

  • According to the QHttp documentation, setProxy needs to come before setHost.
  • The number of inflight requests could easily exceed the number given by MAX_REQ in the case of errors because requestFinished for setProxy and setHost weren't filtered out up front.
  • 404 errors weren't treated at all. As a result, QPixmap would try to parse the HTML of the 404 request.

See patch.txt for the (trivial) fixes.

I have further questions about the code:

  • in my compiled version, QT is not set to threaded, so it doesn't matter, but the code is using vectorMutex.tryLock() instead of vectorMutex.lock(). In the context of where it is used, that doesn't seem to make a lot of sense, but maybe I'm missing something?
  • Overall, when a TMS layer is selected upon startup, merkaartor will always ask for some bogus tile first, presumably because MapView? doesn't have its layout setup yet at startup. So, I'm always seeing it requesting tile 9/256/256.png and such.

Also, coming back to the real problem of this bug: I tried putting a spelling mistake in on of the existing entires and then I'm never seeing a crash! Could it be that this bug ONLY happens when dealing with localhost ?

comment:3 Changed 10 years ago by Chris Browet

Owner: changed from cbro@… to Chris Browet
Status: newassigned

Thanks for your effort.

I've not much availability for Merkaartor right now, unfortunately...

Re:

  • vectorMutex: This is legacy code; Never understood myself but prefered not to touch it, either.
  • MapView?: Yeah, I know. There is some race condition between the loading of initial tiles and the restore of the windows size/postion (which imply a change in the viewport). Never quite succeeded to get it right...
  • The main bug: The strange thing is that it doesn't crash in Merkaartor code, nor in code called by Merkaartor...

Could it be a Qt/Mac? bug in socket handling?

comment:4 Changed 10 years ago by Chris Browet

(In [17843]) FIX : Tiles network patch by Tom Verbeure (refs #2316)

comment:5 Changed 10 years ago by tom_verbeure@…

I see the same crashing problem in the currently released 0.14 binary when I run it in on Windows XP (in a Vmware Fusion virtual machine). It looks like it's crashing in code related to the signals/slots dispatcher. Running a tile server on localhost is obviously an obscure use case... I'm going to look into it a bit more.

comment:6 Changed 10 years ago by tom_verbeure@…

Resolution: fixed
Status: assignedclosed

After compiling to a debug version from source of Qt 4.5.2, I tracked this down to line 268 of src/gui/kernel/qeventdispatcher_mac.mm.

Guess, what, there was a patch for that in Qt two months ago! http://qt.gitorious.com/qt/qt/commit/84abdaa41e6c3bde6ac653e02bd72300b6681572?diffmode=sidebyside

I patched just that in Qt 4.5.2 and the crash behavior has gone.

The crash that I'm seeing in Windows XP may be something else? I can't check because I don't have a development environment for that...

In any case, I believe this bug can be closed...

comment:7 Changed 10 years ago by tom_verbeure@…

Final comment: this probably doesn't crash on Windows after all. The crash on Windows is probably due to bug 2317...

comment:8 Changed 10 years ago by Chris Browet

Thanks for your investigations...

Note: See TracTickets for help on using tickets.