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.
UPDATE:
Below is (part of) the crash log:
Process: QGIS [511]Path: /Applications/QGIS.app/Contents/MacOS/QGISIdentifier: org.qgis.qgis2Version: 2.0.1 (2.0.1 [f738351])Code Type: X86-64 (Native)Parent Process: launchd [262]Responsible: QGIS [511]User ID: 501Date/Time: 2014-05-26 12:58:19.517 +0200OS Version: Mac OS X 10.9.3 (13D65)Report Version: 11Crashed Thread: 0 Dispatch queue: com.apple.main-threadException Type: EXC_BAD_ACCESS (SIGSEGV)Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000VM Regions Near 0:--> __TEXT 000000010a8fd000-000000010af86000 [ 6692K] r-x/rwx SM=COW /Applications/QGIS.app/Contents/MacOS/QGISThread 0 Crashed:: Dispatch queue: com.apple.main-thread0 org.gdal.gdal 0x000000010d45d2bb GDALMultiDomainMetadata::Clear() + 551 org.gdal.gdal 0x000000010d2c0e40 GTiffRasterBand::~GTiffRasterBand() + 322 org.gdal.gdal 0x000000011cce6fb9 GDALDataset::~GDALDataset() + 4853 org.gdal.gdal 0x000000011cb8855d GTiffDataset::~GTiffDataset() + 1174 org.gdal.gdal 0x000000011cce53bb GDALClose + 1465 _gdal.so 0x000000011ca896e7 _wrap_delete_Dataset + 2796 org.python.python 0x000000011a8c3f72 PyObject_Call + 1017 org.python.python 0x000000011a8c07d1 PyObject_CallFunctionObjArgs + 1908 _gdal.so 0x000000011ca69d43 SwigPyObject_dealloc + 949 org.python.python 0x000000011a8ee88f 0x11a8ba000 + 21518310 org.python.python 0x000000011a90db4c 0x11a8ba000 + 34286011 org.python.python 0x000000011a8dfe7c 0x11a8ba000 + 15526012 org.python.python 0x000000011a94087c 0x11a8ba000 + 55103613 org.python.python 0x000000011a93d4d4 PyEval_EvalFrameEx + 1307914 org.python.python 0x000000011a93a093 PyEval_EvalCodeEx + 164115 org.python.python 0x000000011a8e1796 0x11a8ba000 + 16168616 org.python.python 0x000000011a8c3f72 PyObject_Call + 10117 org.python.python 0x000000011a8ce9a7 0x11a8ba000 + 8439118 org.python.python 0x000000011a8c3f72 PyObject_Call + 10119 org.python.python 0x000000011a94001f PyEval_CallObjectWithKeywords + 9320 sip.so 0x000000011ab46d38 sip_api_invoke_slot + 75321 QtCore.so 0x000000011ac6d597 PyQtProxy::invokeSlot(qpycore_slot const&, void**) + 17922 QtCore.so 0x000000011ac6d885 PyQtProxy::unislot(void**) + 11723 QtCore.so 0x000000011ac6d975 PyQtProxy::qt_metacall(QMetaObject::Call, int, void**) + 9524 QtCore 0x000000010f5bc2e2 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 214625 QtGui 0x000000010fee5ef1 QAbstractButton::clicked(bool) + 49
أكثر...
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.
UPDATE:
I get the same error running in Safe Mode.
UPDATE 2:
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 = None the 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.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 = None the 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?
Below is (part of) the crash log:
Process: QGIS [511]Path: /Applications/QGIS.app/Contents/MacOS/QGISIdentifier: org.qgis.qgis2Version: 2.0.1 (2.0.1 [f738351])Code Type: X86-64 (Native)Parent Process: launchd [262]Responsible: QGIS [511]User ID: 501Date/Time: 2014-05-26 12:58:19.517 +0200OS Version: Mac OS X 10.9.3 (13D65)Report Version: 11Crashed Thread: 0 Dispatch queue: com.apple.main-threadException Type: EXC_BAD_ACCESS (SIGSEGV)Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000VM Regions Near 0:--> __TEXT 000000010a8fd000-000000010af86000 [ 6692K] r-x/rwx SM=COW /Applications/QGIS.app/Contents/MacOS/QGISThread 0 Crashed:: Dispatch queue: com.apple.main-thread0 org.gdal.gdal 0x000000010d45d2bb GDALMultiDomainMetadata::Clear() + 551 org.gdal.gdal 0x000000010d2c0e40 GTiffRasterBand::~GTiffRasterBand() + 322 org.gdal.gdal 0x000000011cce6fb9 GDALDataset::~GDALDataset() + 4853 org.gdal.gdal 0x000000011cb8855d GTiffDataset::~GTiffDataset() + 1174 org.gdal.gdal 0x000000011cce53bb GDALClose + 1465 _gdal.so 0x000000011ca896e7 _wrap_delete_Dataset + 2796 org.python.python 0x000000011a8c3f72 PyObject_Call + 1017 org.python.python 0x000000011a8c07d1 PyObject_CallFunctionObjArgs + 1908 _gdal.so 0x000000011ca69d43 SwigPyObject_dealloc + 949 org.python.python 0x000000011a8ee88f 0x11a8ba000 + 21518310 org.python.python 0x000000011a90db4c 0x11a8ba000 + 34286011 org.python.python 0x000000011a8dfe7c 0x11a8ba000 + 15526012 org.python.python 0x000000011a94087c 0x11a8ba000 + 55103613 org.python.python 0x000000011a93d4d4 PyEval_EvalFrameEx + 1307914 org.python.python 0x000000011a93a093 PyEval_EvalCodeEx + 164115 org.python.python 0x000000011a8e1796 0x11a8ba000 + 16168616 org.python.python 0x000000011a8c3f72 PyObject_Call + 10117 org.python.python 0x000000011a8ce9a7 0x11a8ba000 + 8439118 org.python.python 0x000000011a8c3f72 PyObject_Call + 10119 org.python.python 0x000000011a94001f PyEval_CallObjectWithKeywords + 9320 sip.so 0x000000011ab46d38 sip_api_invoke_slot + 75321 QtCore.so 0x000000011ac6d597 PyQtProxy::invokeSlot(qpycore_slot const&, void**) + 17922 QtCore.so 0x000000011ac6d885 PyQtProxy::unislot(void**) + 11723 QtCore.so 0x000000011ac6d975 PyQtProxy::qt_metacall(QMetaObject::Call, int, void**) + 9524 QtCore 0x000000010f5bc2e2 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 214625 QtGui 0x000000010fee5ef1 QAbstractButton::clicked(bool) + 49
أكثر...