I'm developing a plugin for QGIS called DEMtools. It runs fine on my linux machine, but is causing me headaches when run on Mac OS X Mavericks (surprise, surprise). I keep getting segmentation faults that look like they are caused by GDAL accessing a GTiffDataset.
Does anyone have any experience debugging these kinds of problems with qgis plugins in the Mac OS X environment? For starters I'd like to know where in my code this goes pear shaped, but as it crashes QGIS entirely, printing messages to the QGIS python console isn't an option.
I get the same error running in Safe Mode.
I've got Eclipse+PyDev up and running for better debugging. This post is helpful with that. I've identified the problem, but I haven't found a fix yet.
As should have been clear initially from the first 6 lines of the backtrace, the problem is the GDALClose. My code didn't explicitly close the dataset and was relying on the gdal
__del__method after it moved out of scope.
However, even when I explicitly close the data set,
dataSet = Nonethe same problem occurs within QGIS.
When I open the python editor from the terminal I can use the gdal module to open and close the same file all day without a problem. (and as stated earlier, it works in linux) I am very close to being totally stumped. Any thoughts?
Also, I'd be really interested to know if any one can successfully run the plugin and/or duplicate this error in the Mac environment.
Below is (part of) the crash log:
Process: QGIS  Path: /Applications/QGIS.app/Contents/MacOS/QGIS Identifier: org.qgis.qgis2 Version: 2.0.1 (2.0.1 [f738351]) Code Type: X86-64 (Native) Parent Process: launchd  Responsible: QGIS  User ID: 501 Date/Time: 2014-05-26 12:58:19.517 +0200 OS Version: Mac OS X 10.9.3 (13D65) Report Version: 11 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 VM Regions Near 0: --> __TEXT 000000010a8fd000-000000010af86000 [ 6692K] r-x/rwx SM=COW /Applications/QGIS.app/Contents/MacOS/QGIS Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 org.gdal.gdal 0x000000010d45d2bb GDALMultiDomainMetadata::Clear() + 55 1 org.gdal.gdal 0x000000010d2c0e40 GTiffRasterBand::~GTiffRasterBand() + 32 2 org.gdal.gdal 0x000000011cce6fb9 GDALDataset::~GDALDataset() + 485 3 org.gdal.gdal 0x000000011cb8855d GTiffDataset::~GTiffDataset() + 117 4 org.gdal.gdal 0x000000011cce53bb GDALClose + 146 5 _gdal.so 0x000000011ca896e7 _wrap_delete_Dataset + 279 6 org.python.python 0x000000011a8c3f72 PyObject_Call + 101 7 org.python.python 0x000000011a8c07d1 PyObject_CallFunctionObjArgs + 190 8 _gdal.so 0x000000011ca69d43 SwigPyObject_dealloc + 94 9 org.python.python 0x000000011a8ee88f 0x11a8ba000 + 215183 10 org.python.python 0x000000011a90db4c 0x11a8ba000 + 342860 11 org.python.python 0x000000011a8dfe7c 0x11a8ba000 + 155260 12 org.python.python 0x000000011a94087c 0x11a8ba000 + 551036 13 org.python.python 0x000000011a93d4d4 PyEval_EvalFrameEx + 13079 14 org.python.python 0x000000011a93a093 PyEval_EvalCodeEx + 1641 15 org.python.python 0x000000011a8e1796 0x11a8ba000 + 161686 16 org.python.python 0x000000011a8c3f72 PyObject_Call + 101 17 org.python.python 0x000000011a8ce9a7 0x11a8ba000 + 84391 18 org.python.python 0x000000011a8c3f72 PyObject_Call + 101 19 org.python.python 0x000000011a94001f PyEval_CallObjectWithKeywords + 93 20 sip.so 0x000000011ab46d38 sip_api_invoke_slot + 753 21 QtCore.so 0x000000011ac6d597 PyQtProxy::invokeSlot(qpycore_slot const&, void**) + 179 22 QtCore.so 0x000000011ac6d885 PyQtProxy::unislot(void**) + 117 23 QtCore.so 0x000000011ac6d975 PyQtProxy::qt_metacall(QMetaObject::Call, int, void**) + 95 24 QtCore 0x000000010f5bc2e2 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 2146 25 QtGui 0x000000010fee5ef1 QAbstractButton::clicked(bool) + 49