Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXC_BAD_ACCESS when using IPC on OS X #417

Closed
LogicalChaos opened this issue Jul 27, 2016 · 6 comments
Closed

EXC_BAD_ACCESS when using IPC on OS X #417

LogicalChaos opened this issue Jul 27, 2016 · 6 comments

Comments

@LogicalChaos
Copy link

Running 10.12 Beta, Apple LLVM version 7.3.0, Qt 5.7 installed with native installer, building under CLion in Debug mode. CloudCompare is consistently on crashing on trunk in ccProgressDialog. I've attached the data files, Rock1 is the model, Rock2 is the data. Running with default parameters it crashes quickly, when reducing the final overlap (25%), it runs for longer or succeeds in the mapping, but still fails more often than not.

I had the same problem running Qt 5.6.1 installed with MacPorts

ccProgressDialog::ccProgressDialog(this=0x00007f8880291030)::$_0::operator()() const + 24 at ccProgressDialog.cpp:49
(lldb) bt
* thread #1: tid = 0x27190b, 0x0000000111127c89 QtGui`QRasterPaintEngine::drawTextItem(QPointF const&, QTextItem const&) + 73, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1c0)
  * frame #0: 0x0000000111127c89 QtGui`QRasterPaintEngine::drawTextItem(QPointF const&, QTextItem const&) + 73
    frame #1: 0x0000000111142529 QtGui`QPainterPrivate::drawTextItem(QPointF const&, QTextItem const&, QTextEngine*) + 2601
    frame #2: 0x0000000110ff167a QtGui`QTextLine::draw(QPainter*, QPointF const&, QTextLayout::FormatRange const*) const + 3354
    frame #3: 0x0000000111141660 QtGui`qt_format_text(QFont const&, QRectF const&, int, QTextOption const*, QString const&, QRectF*, int, int*, int, QPainter*) + 4688
    frame #4: 0x00000001111403da QtGui`QPainter::drawText(QRect const&, int, QString const&, QRect*) + 506
    frame #5: 0x0000000110869cef QtWidgets`QStyle::drawItemText(QPainter*, QRect const&, int, QPalette const&, bool, QString const&, QPalette::ColorRole) const + 543
    frame #6: 0x000000011093d892 QtWidgets`QLabel::paintEvent(QPaintEvent*) + 2546
    frame #7: 0x000000011083ce9a QtWidgets`QWidget::event(QEvent*) + 2154
    frame #8: 0x0000000110936edd QtWidgets`QFrame::event(QEvent*) + 45
    frame #9: 0x000000011093ce82 QtWidgets`QLabel::event(QEvent*) + 258
    frame #10: 0x00000001107fcedd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #11: 0x00000001107ff822 QtWidgets`QApplication::notify(QObject*, QEvent*) + 5906
    frame #12: 0x000000011165faa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #13: 0x00000001108367cb QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 3467
    frame #14: 0x0000000110836ff8 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 1192
    frame #15: 0x0000000110836e86 QtWidgets`QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 822
    frame #16: 0x0000000110836a70 QtWidgets`QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) + 4144
    frame #17: 0x000000011080a63c QtWidgets`QWidgetBackingStore::doSync() + 4956
    frame #18: 0x000000011083d0cc QtWidgets`QWidget::event(QEvent*) + 2716
    frame #19: 0x00000001107fcedd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #20: 0x00000001107ff822 QtWidgets`QApplication::notify(QObject*, QEvent*) + 5906
    frame #21: 0x000000011165faa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #22: 0x00000001108063ec QtWidgets`QWidgetBackingStore::sendUpdateRequest(QWidget*, QWidgetBackingStore::UpdateTime) + 252
    frame #23: 0x0000000110806b79 QtWidgets`QWidgetBackingStore::markDirty(QRect const&, QWidget*, QWidgetBackingStore::UpdateTime, QWidgetBackingStore::BufferState) + 153
    frame #24: 0x0000000110840193 QtWidgets`QWidget::repaint(QRect const&) + 195
    frame #25: 0x00000001108400c4 QtWidgets`QWidget::repaint() + 52
    frame #26: 0x000000010dab85b8 libQCC_DB_LIBd.dylib`ccProgressDialog::ccProgressDialog(this=0x00007f8880291030)::$_0::operator()() const + 24 at ccProgressDialog.cpp:49
    frame #27: 0x000000010dab8589 libQCC_DB_LIBd.dylib`QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, ccProgressDialog::ccProgressDialog(bool, QWidget*)::$_0>::call(f=0x00007f8880291030, arg=0x00007f887bd76080)::$_0&, void**) + 25 at qobjectdefs_impl.h:501
    frame #28: 0x000000010dab8541 libQCC_DB_LIBd.dylib`_ZN9QtPrivate7FunctorIZN16ccProgressDialogC1EbP7QWidgetE3$_0Li0EE4callINS_4ListIJEEEvEEvRS4_PvPSA_(f=0x00007f8880291030, (null)=0x00007fff52de5720, arg=0x00007f887bd76080) + 33 at qobjectdefs_impl.h:558
    frame #29: 0x000000010dab84cd libQCC_DB_LIBd.dylib`QtPrivate::QFunctorSlotObject<ccProgressDialog::ccProgressDialog(bool, QWidget*)::$_0, 0, QtPrivate::List<>, void>::impl(which=1, this_=0x00007f8880291020, r=0x00007fff52de5720, a=0x00007f887bd76080, ret=0x0000000000000000) + 141 at qobject_impl.h:198
    frame #30: 0x00000001116899ec QtCore`QObject::event(QEvent*) + 156
    frame #31: 0x000000011083d69b QtWidgets`QWidget::event(QEvent*) + 4203
    frame #32: 0x00000001107fcedd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #33: 0x00000001107ff822 QtWidgets`QApplication::notify(QObject*, QEvent*) + 5906
    frame #34: 0x000000011165faa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #35: 0x00000001116606d8 QtCore`QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 600
    frame #36: 0x0000000113cdbd6e libqcocoa.dylib`QCocoaEventDispatcherPrivate::processPostedEvents() + 190
    frame #37: 0x0000000113cdb2c0 libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1552
    frame #38: 0x000000010dab8198 libQCC_DB_LIBd.dylib`ccProgressDialog::update(this=0x00007fff52de5720, percent=31.3131371) + 168 at ccProgressDialog.cpp:89
    frame #39: 0x000000010f6c6070 libCC_CORE_LIBd.dylib`CCLib::NormalizedProgress::oneStep(this=0x00007f88802c68e0) + 128 at NormalizedProgress.cpp:139
    frame #40: 0x000000010f688b9c libCC_CORE_LIBd.dylib`CCLib::DistanceComputationTools::computeCellHausdorffDistance(cell=0x00007fff52de2960, additionalParameters=0x00007fff52de39f0, nProgress=0x00007f88802c68e0) + 1228 at DistanceComputationTools.cpp:482
    frame #41: 0x000000010f676067 libCC_CORE_LIBd.dylib`LaunchOctreeCellFunc_MT(desc=0x00007f887c9d07e8) + 359 at DgmOctree.cpp:3229
    frame #42: 0x000000010f685dbd libCC_CORE_LIBd.dylib`QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&>::operator(this=0x00007f88802c3f98, u=0x00007f887c9d07e8)(octreeCellDesc const&) + 29 at qtconcurrentfunctionwrappers.h:83
    frame #43: 0x000000010f6848f6 libCC_CORE_LIBd.dylib`QtConcurrent::MapKernel<std::__1::__wrap_iter<octreeCellDesc*>, QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&> >::runIteration(this=0x00007f88802c3f60, it=__wrap_iter<octreeCellDesc *> @ 0x00007fff52de2a00, (null)=831, (null)=0x0000000000000000) + 54 at qtconcurrentmapkernel.h:69
    frame #44: 0x000000010f684a0b libCC_CORE_LIBd.dylib`QtConcurrent::MapKernel<std::__1::__wrap_iter<octreeCellDesc*>, QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&> >::runIterations(this=0x00007f88802c3f60, sequenceBeginIterator=__wrap_iter<octreeCellDesc *> @ 0x00007fff52de2a78, beginIndex=831, endIndex=833, (null)=0x0000000000000000) + 251 at qtconcurrentmapkernel.h:78
    frame #45: 0x000000010f684eb7 libCC_CORE_LIBd.dylib`QtConcurrent::IterateKernel<std::__1::__wrap_iter<octreeCellDesc*>, void>::forThreadFunction(this=0x00007f88802c3f60) + 503 at qtconcurrentiteratekernel.h:256
    frame #46: 0x000000010f684607 libCC_CORE_LIBd.dylib`QtConcurrent::IterateKernel<std::__1::__wrap_iter<octreeCellDesc*>, void>::threadFunction(this=0x00007f88802c3f60) + 39 at qtconcurrentiteratekernel.h:218
    frame #47: 0x000000011077aacc QtConcurrent`QtConcurrent::ThreadEngineBase::startBlocking() + 108
    frame #48: 0x000000010f685e29 libCC_CORE_LIBd.dylib`QtConcurrent::ThreadEngine<void>::startBlocking(this=0x00007f88802c3f60) + 41 at qtconcurrentthreadengine.h:154
    frame #49: 0x000000010f683f9f libCC_CORE_LIBd.dylib`QtConcurrent::ThreadEngineStarter<void>::startBlocking(this=0x00007fff52de2cd0) + 31 at qtconcurrentthreadengine.h:257
    frame #50: 0x000000010f67b836 libCC_CORE_LIBd.dylib`void QtConcurrent::blockingMap<std::__1::vector<octreeCellDesc, std::__1::allocator<octreeCellDesc> >, void (*)(octreeCellDesc const&)>(sequence=size=3333, map=(libCC_CORE_LIBd.dylib`LaunchOctreeCellFunc_MT(octreeCellDesc const&) at DgmOctree.cpp:3212))(octreeCellDesc const&)) + 278 at qtconcurrentmap.h:193
    frame #51: 0x000000010f677548 libCC_CORE_LIBd.dylib`CCLib::DgmOctree::executeFunctionForAllCellsAtLevel(this=0x00007f887c21a400, level='\x05', func=(libCC_CORE_LIBd.dylib`CCLib::DistanceComputationTools::computeCellHausdorffDistance(CCLib::DgmOctree::octreeCell const&, void**, CCLib::NormalizedProgress*) at DistanceComputationTools.cpp:419), additionalParameters=0x00007fff52de39f0, multiThread=true, progressCb=0x00007fff52de5720, functionTitle="Cloud-Cloud Distance", maxThreadCount=4)(CCLib::DgmOctree::octreeCell const&, void**, CCLib::NormalizedProgress*), void**, bool, CCLib::GenericProgressCallback*, char const*, int) + 5096 at DgmOctree.cpp:3476
    frame #52: 0x000000010f687850 libCC_CORE_LIBd.dylib`CCLib::DistanceComputationTools::computeCloud2CloudDistance(comparedCloud=0x00007f88806176e0, referenceCloud=0x00007f888047a740, params=0x00007fff52de4288, progressCb=0x00007fff52de5720, compOctree=0x0000000000000000, refOctree=0x0000000000000000) + 1536 at DistanceComputationTools.cpp:243
    frame #53: 0x000000010f6d4c02 libCC_CORE_LIBd.dylib`CCLib::ICPRegistrationTools::Register(inputModelCloud=0x00007f8880446e60, inputModelMesh=0x0000000000000000, inputDataCloud=0x00007f88804f6200, params=0x00007fff52de5520, transform=0x00007fff52de5560, finalRMS=0x00007fff52de6098, finalPointCount=0x00007fff52de608c, progressCb=0x00007fff52de5720) + 4290 at RegistrationTools.cpp:365
    frame #54: 0x000000010cfdf6b0 CloudCompare`ccRegistrationTools::ICP(data=0x00007f8880457dc0, model=0x00007f8880446e60, transMat=0x00007fff52de60a0, finalScale=0x00007fff52de6090, finalRMS=0x00007fff52de6098, finalPointCount=0x00007fff52de608c, minRMSDecrease=0.000010000000000000001, maxIterationCount=20, randomSamplingLimit=50000, removeFarthestPoints=false, method=MAX_ITER_CONVERGENCE, adjustScale=false, finalOverlapRatio=0.78926702559029849, useDataSFAsWeights=false, useModelSFAsWeights=false, filters=0, maxThreadCount=4, parent=0x00007f887c0a7400) + 6912 at ccRegistrationTools.cpp:276
    frame #55: 0x000000010d055c0c CloudCompare`MainWindow::doActionRegister(this=0x00007f887c0a7400) + 1324 at mainwindow.cpp:3625
    frame #56: 0x000000010d0fef14 CloudCompare`MainWindow::qt_static_metacall(_o=0x00007f887c0a7400, _c=InvokeMetaMethod, _id=106, _a=0x00007fff52de6560) + 2148 at moc_mainwindow.cpp:959
    frame #57: 0x0000000111690923 QtCore`QMetaObject::activate(QObject*, int, int, void**) + 883
    frame #58: 0x00000001107f3e4f QtWidgets`QAction::activate(QAction::ActionEvent) + 303
    frame #59: 0x00000001108eb648 QtWidgets`QAbstractButtonPrivate::click() + 88
    frame #60: 0x00000001108ec7ae QtWidgets`QAbstractButton::mouseReleaseEvent(QMouseEvent*) + 270
    frame #61: 0x00000001109c193f QtWidgets`QToolButton::mouseReleaseEvent(QMouseEvent*) + 15
    frame #62: 0x000000011083ccc1 QtWidgets`QWidget::event(QEvent*) + 1681
    frame #63: 0x00000001108ec4ff QtWidgets`QAbstractButton::event(QEvent*) + 175
    frame #64: 0x00000001109c1ef3 QtWidgets`QToolButton::event(QEvent*) + 323
    frame #65: 0x00000001107fcedd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #66: 0x00000001108005f0 QtWidgets`QApplication::notify(QObject*, QEvent*) + 9440
    frame #67: 0x000000011165faa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #68: 0x00000001107fd847 QtWidgets`QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 871
    frame #69: 0x000000011085d52b QtWidgets`QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1387
    frame #70: 0x000000011085c5bf QtWidgets`QWidgetWindow::event(QEvent*) + 175
    frame #71: 0x00000001107fcedd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #72: 0x00000001107ff822 QtWidgets`QApplication::notify(QObject*, QEvent*) + 5906
    frame #73: 0x000000011165faa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #74: 0x0000000110ef188a QtGui`QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2794
    frame #75: 0x0000000110edb06b QtGui`QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 155
    frame #76: 0x0000000113cdc631 libqcocoa.dylib`QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 33
    frame #77: 0x00007fffbdc33161 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #78: 0x00007fffbdc1331d CoreFoundation`__CFRunLoopDoSources0 + 557
    frame #79: 0x00007fffbdc12816 CoreFoundation`__CFRunLoopRun + 934
    frame #80: 0x00007fffbdc1220d CoreFoundation`CFRunLoopRunSpecific + 285
    frame #81: 0x00007fffbd1d3bcc HIToolbox`RunCurrentEventLoopInMode + 240
    frame #82: 0x00007fffbd1d3909 HIToolbox`ReceiveNextEventCommon + 184
    frame #83: 0x00007fffbd1d3836 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #84: 0x00007fffbb947a91 AppKit`_DPSNextEvent + 1093
    frame #85: 0x00007fffbc051704 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1658
    frame #86: 0x00007fffbb93c409 AppKit`-[NSApplication run] + 926
    frame #87: 0x0000000113cdb53f libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2191
    frame #88: 0x000000011165beb1 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 401
    frame #89: 0x0000000111660115 QtCore`QCoreApplication::exec() + 341
    frame #90: 0x000000010d033bcc CloudCompare`main(argc=1, argv=0x00007fff52de94d8) + 8220 at main.cpp:386
    frame #91: 0x00007fffd1f87255 libdyld.dylib`start + 1
    frame #92: 0x00007fffd1f87255 libdyld.dylib`start + 1

Running with 25% final overlap.

ccProgressDialog::update(this=0x00007fff57491720, percent=12.121213) + 85 at ccProgressDialog.cpp:80
(lldb) bt
* thread #9: tid = 0x281654, 0x00007fffd20b5de6 libsystem_kernel.dylib`__pthread_kill + 10, name = 'Thread (pooled)', stop reason = signal SIGABRT
  * frame #0: 0x00007fffd20b5de6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fffd219f92b libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fffd201b4dc libsystem_c.dylib`abort + 129
    frame #3: 0x00007fffd210b6c7 libsystem_malloc.dylib`free + 520
    frame #4: 0x000000010c1609f1 QtWidgets`QWidgetBackingStore::doSync() + 1809
    frame #5: 0x000000010c1940cc QtWidgets`QWidget::event(QEvent*) + 2716
    frame #6: 0x000000010c153edd QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 269
    frame #7: 0x000000010c156822 QtWidgets`QApplication::notify(QObject*, QEvent*) + 5906
    frame #8: 0x000000010cfb1aa4 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
    frame #9: 0x000000010c15d3ec QtWidgets`QWidgetBackingStore::sendUpdateRequest(QWidget*, QWidgetBackingStore::UpdateTime) + 252
    frame #10: 0x000000010c15db79 QtWidgets`QWidgetBackingStore::markDirty(QRect const&, QWidget*, QWidgetBackingStore::UpdateTime, QWidgetBackingStore::BufferState) + 153
    frame #11: 0x000000010c197193 QtWidgets`QWidget::repaint(QRect const&) + 195
    frame #12: 0x000000010c1970c4 QtWidgets`QWidget::repaint() + 52
    frame #13: 0x000000010c2e11ab QtWidgets`QProgressBar::setValue(int) + 267
    frame #14: 0x000000010c3801a5 QtWidgets`QProgressDialog::setValue(int) + 69
    frame #15: 0x000000010940e145 libQCC_DB_LIBd.dylib`ccProgressDialog::update(this=0x00007fff57491720, percent=12.121213) + 85 at ccProgressDialog.cpp:80
    frame #16: 0x000000010b019070 libCC_CORE_LIBd.dylib`CCLib::NormalizedProgress::oneStep(this=0x00007f8d55d19b70) + 128 at NormalizedProgress.cpp:139
    frame #17: 0x000000010afdbb9c libCC_CORE_LIBd.dylib`CCLib::DistanceComputationTools::computeCellHausdorffDistance(cell=0x0000700007523b10, additionalParameters=0x00007fff5748f9f0, nProgress=0x00007f8d55d19b70) + 1228 at DistanceComputationTools.cpp:482
    frame #18: 0x000000010afc9067 libCC_CORE_LIBd.dylib`LaunchOctreeCellFunc_MT(desc=0x00007f8d52a71590) + 359 at DgmOctree.cpp:3229
    frame #19: 0x000000010afd8dbd libCC_CORE_LIBd.dylib`QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&>::operator(this=0x00007f8d55d1d3a8, u=0x00007f8d52a71590)(octreeCellDesc const&) + 29 at qtconcurrentfunctionwrappers.h:83
    frame #20: 0x000000010afd78f6 libCC_CORE_LIBd.dylib`QtConcurrent::MapKernel<std::__1::__wrap_iter<octreeCellDesc*>, QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&> >::runIteration(this=0x00007f8d55d1d370, it=__wrap_iter<octreeCellDesc *> @ 0x0000700007523bb0, (null)=294, (null)=0x0000000000000000) + 54 at qtconcurrentmapkernel.h:69
    frame #21: 0x000000010afd7a0b libCC_CORE_LIBd.dylib`QtConcurrent::MapKernel<std::__1::__wrap_iter<octreeCellDesc*>, QtConcurrent::FunctionWrapper1<void, octreeCellDesc const&> >::runIterations(this=0x00007f8d55d1d370, sequenceBeginIterator=__wrap_iter<octreeCellDesc *> @ 0x0000700007523c28, beginIndex=293, endIndex=295, (null)=0x0000000000000000) + 251 at qtconcurrentmapkernel.h:78
    frame #22: 0x000000010afd7eb7 libCC_CORE_LIBd.dylib`QtConcurrent::IterateKernel<std::__1::__wrap_iter<octreeCellDesc*>, void>::forThreadFunction(this=0x00007f8d55d1d370) + 503 at qtconcurrentiteratekernel.h:256
    frame #23: 0x000000010afd7607 libCC_CORE_LIBd.dylib`QtConcurrent::IterateKernel<std::__1::__wrap_iter<octreeCellDesc*>, void>::threadFunction(this=0x00007f8d55d1d370) + 39 at qtconcurrentiteratekernel.h:218
    frame #24: 0x000000010c0d2f79 QtConcurrent`QtConcurrent::ThreadEngineBase::run() + 169
    frame #25: 0x000000010cdf2a08 QtCore`QThreadPoolThread::run() + 120
    frame #26: 0x000000010cdf5b3a QtCore`QThreadPrivate::start(void*) + 362
    frame #27: 0x00007fffd219cc4f libsystem_pthread.dylib`_pthread_body + 176
    frame #28: 0x00007fffd219cb9f libsystem_pthread.dylib`_pthread_start + 274
    frame #29: 0x00007fffd219c3d5 libsystem_pthread.dylib`thread_start + 13

rocks.tar.zip

@LogicalChaos
Copy link
Author

It looks like in ccProgressDialog::update, keeping the mutex across the refresh operation fixes the problem (for me at least). I'd be happy to put in a pull, or if someone wants to apply the attached patch...

cc_mutex.txt

@dgirardeau
Copy link
Member

Interesting... I wonder why it crahsed... and why unlocking the mutex later fixes the issue :D

I'll test this on my side and let you know.

Thanks for the feedback anyway (and for the patch).

@LogicalChaos
Copy link
Author

On Jul 27, 2016, at 2:10 PM, CloudCompare administrator notifications@github.com wrote:

Interesting... I wonder why it crahsed... and why unlocking the mutex later fixes the issue :D

What I saw was one of the other threads sitting at QCoreApplication::processEvents() during the crash. So, I was thinking that call was not thread safe and moved the mutex unlock and it worked. The Qt docs indicate it is thread safe, so holding the mutex longer may be masking another problem, but to a good effect. QProgressDialog::repaint has no mention of thread safety, although it’s doc suggests that QProgressDialog::update may be a more appropriate call to use. Not that I’ve never used Qt before, so YMMV.
I'll test this on my side and let you know.

Please, since I only hit OS X on one version of Qt.
Thanks for the feedback anyway (and for the patch).

You’re welcome.

@dgirardeau
Copy link
Member

dgirardeau commented Jul 28, 2016

Well, with your patch it crashes on my side (Windows,Qt 5.6 and Visual Studio 2013).

I agree that it probably masks something else. The mutex is just here to protect the few members of the class. Therefore there's no reason to leave it locked after having modified them (the next calls are made to native Qt methods only, therefore the class members won't be read or write).

Anyway I updated the code to make it much simpler (with Qt 5 we can more easily use QAtomicInt instead of int values, etc.). Can you tell me if it fixes your issue?

P.S.: Here is the longer story:

  • in CloudCompare, the progress dialog (notably the update method) can be called by several threads at the same time (this is why we must use a mutex).
  • moreover, when parallel algorithms are running, it is likely that all cores will be intensively used. In this case the GUI doesn't have the time to refresh itself because the computation threads prevent the main thread from running. Qt only handles the GUI elements in the main thread. And we can't make a direct call to QProgressDialog::repaint from another thread than the main one. Therefore we have to send a signal triggering the repaint event, and then we have to let the main thread breath (QCoreApplication::processEvents()). This signal mechanism is thread safe (by default signals are stacked when they are exchanged between two different threads). And they are processed sequentially by the main thread.
  • we call repaint instead of update because the first one forces the redraw while the second one only schedules another repaint itself.

@LogicalChaos
Copy link
Author

Yes, this fixes the problem I was seeing. Thanks for the Qt education also.

Why wouldn't you use std::atomic_int (std::atomic<int>) rather than QAtomicInt? When I switched, it appeared to work just as well. I chased through QAtomicInt a ways, there is a lot of code behind it. std::atomic_int is a C++11 language standard. In CMakeSetCompilerOptions.cmake, C++11 is required on *nix, and I'm sure Windows, although there is no explicit callout for it. Presumably something MVSC?

Genuinly curions, not busting on you.

@dgirardeau
Copy link
Member

Yes, since version 2.7 we are now using c++11 compiles only... But I need to get used to it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants