The Crystal Programming Language Forum

How to debug c++ library

I use qt binding and get this error, link to debug version dylib, but no c++ symbol info.

Invalid memory access (signal 11) at address 0x0
[0x1037a652b] *CallStack::print_backtrace:Int32 +107
[0x103789966] __crystal_sigfault_handler +262
[0x7fff71c1542d] _sigtramp +29
[0x7fff3ae8452f] _ZNSt3__16__treeIPN2CI4NodeENS_4lessIS3_EENS_9allocatorIS3_EEE7destroyEPNS_11__tree_nodeIS3_PvEE +19
[0x7fff3ae84542] _ZNSt3__16__treeIPN2CI4NodeENS_4lessIS3_EENS_9allocatorIS3_EEE7destroyEPNS_11__tree_nodeIS3_PvEE +38
[0x7fff3ae84536] _ZNSt3__16__treeIPN2CI4NodeENS_4lessIS3_EENS_9allocatorIS3_EEE7destroyEPNS_11__tree_nodeIS3_PvEE +26
[0x7fff3ae72440] _ZNK2CI4Node18unique_child_countEv +114
[0x7fff3b0adb86] ___ZNK2CI11ProgramNode21compute_kernel_digestEPKNS_7ContextE_block_invoke +308
[0x7fff3b0acb28] ___ZNK2CI11ProgramNode33traverse_graph_preorder_stoppableEU13block_pointerFbPNS_4NodeES2_iiiE_block_invoke +127
[0x7fff3ae5d0fb] _ZN2CI11GraphObject27traverse_preorder_stoppableEPS0_S1_iiU13block_pointerFbS1_S1_iiE +219
[0x7fff3ae722fa] _ZNK2CI11ProgramNode33traverse_graph_preorder_stoppableEU13block_pointerFbPNS_4NodeES2_iiiE +138
[0x7fff3ae7218d] _ZNK2CI11ProgramNode21compute_kernel_digestEPKNS_7ContextE +171
[0x7fff3ae71e16] _ZN2CI11ProgramNode28create_program_and_argumentsEPNS_7ContextEPKc +526
[0x7fff3ae5bcbc] _ZN2CI11GraphObject15traverse_uniqueEPS0_U13block_pointerFvS1_S1_iiiE +220
[0x7fff3ae696b0] _ZN2CIL14recursive_tileEPNS_10RenderTaskEPNS_7ContextEPKNS_17RenderDestinationEPKcPNS_4NodeERK6CGRectNS_11PixelFormatERKNS_12swizzle_infoEU13block_pointerFPNS_8TileTaskEPNS_11ProgramNodeESB_E +1175
[0x7fff3ae68e1d] _ZN2CIL15tile_node_graphEPNS_7ContextEPKNS_17RenderDestinationEPKcPNS_4NodeERK6CGRectNS_11PixelFormatERKNS_12swizzle_infoEU13block_pointerFPNS_8TileTaskEPNS_11ProgramNodeES9_E +475
[0x7fff3ae68953] _ZN2CI16image_get_bitmapEPNS_7ContextEPNS_5ImageE6CGRectP12CGColorSpacePNS_6BitmapEPKNS_17RenderDestinationE +1939
[0x7fff3ae68165] _ZNK2CI14RenderToBitmap6renderEPNS_5ImageEPNS_7ContextE +451
[0x7fff3ae67a39] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:] +3699
[0x7fff3ae66bbf] -[CIContext(CIRenderDestination) startTaskToRender:toDestination:error:] +31
[0x7fff3ae6691f] -[CIContext(CIRenderDestination) startTaskToRender:fromRect:toDestination:atPoint:error:] +190
[0x7fff3ae57496] -[CIContext(createCGImage) _createCGImage:fromRect:format:colorSpace:deferred:] +4062
[0x7fff5351ff40] _ZNK11CUIRenderer35CreateImageByApplyingEffectsToImageEPK13CUIDescriptorlPK9__CFArrayP7CGImagedhhR11CGBlendModeb +14324
[0x7fff5351b723] _ZNK11CUIRenderer11CreateImageE6CGRectlPK13CUIDescriptorhPP7CGImagePxPhP11CGBlendMode +5589
[0x7fff53519e85] _ZNK11CUIRenderer9DrawImageE6CGRectlPK13CUIDescriptor +147
[0x7fff5351944f] _ZN20CUICoreThemeRenderer13DrawMenuTitleEPK13CUIDescriptorR13CUIReturnInfo +813
[0x7fff53518565] _ZN11CUIRenderer4DrawE6CGRectP9CGContextPK14__CFDictionaryPS5_ +1785
[0x7fff53517e3a] CUIDraw +278
[0x7fff38f100c2] _HIThemeCUIDrawWithOptions +107
[0x7fff38f1003c] _HIThemeCUIDrawWithRenderer +173
[0x7fff38f0f3b4] _HIThemeDrawAppleMenuTitle +510
[0x7fff38f0ba1d] _ZN13HIMenuBarView8DrawOnceE6CGRectS0_bbP9CGContext +1089
[0x7fff38f0b56d] _ZN13HIMenuBarView8DrawSelfEsPK9__HIShapeP9CGContext +689
[0x7fff38f0af3e] _ZN13HIMenuBarView24DrawWithoutCustomizationEsPK9__HIShapeP9CGContext +82
[0x7fff38f0aed6] _ZN13HIMenuBarView22DrawingDelegateHandlerEP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv +258
[0x7fff38eef711] _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec +1419
[0x7fff38eeeae0] _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec +338
[0x7fff38eee983] SendEventToEventTargetWithOptions +45
[0x7fff38f0aa4b] _ZN6HIView8SendDrawEsP13OpaqueGrafPtrPK9__HIShapeP9CGContext +325
[0x7fff38f0a4be] _ZN6HIView23RecursiveDrawCompositedEPK9__HIShapeS2_jPS_P9CGContexthd +582
[0x7fff38f0a709] _ZN6HIView23RecursiveDrawCompositedEPK9__HIShapeS2_jPS_P9CGContexthd +1169
[0x7fff38f09ef9] _ZN6HIView14DrawCompositedEsP13OpaqueGrafPtrPK9__HIShapejPS_P9CGContext +815
[0x7fff38f09bbb] _ZN6HIView6RenderEjP9CGContext +51
[0x7fff38f092e9] _ZN10WindowData20PrepareForVisibilityEv +153
[0x7fff38f5f464] _ShowHideWindows +286
[0x7fff38f08d30] ShowHide +35
[0x7fff38ef8f0b] _ZN9MBWindows18GetWindowOnDisplayEjh +289
[0x7fff38ef8cef] _ZN15MenuBarInstance15ForEachWindowDoEhU13block_pointerFbP15OpaqueWindowPtrjE +183
[0x7fff38ef8bef] _ZN15MenuBarInstance28SetBoundsAndUpdateResolutionEv +103
[0x7fff38ef876a] _ZN15MenuBarInstance4ShowE21MenuBarAnimationStylehhhh +280
[0x7fff38ef81a1] _ZN15MenuBarInstance21UpdateAggregateUIModeE21MenuBarAnimationStylehhh +805
[0x7fff38ef7daa] _ZN15MenuBarInstance16ForEachMenuBarDoEU13block_pointerFvPS_E +46
[0x7fff38ef7d4a] _ZL25UpdateAllAggregateUIModes21MenuBarAnimationStyleh +126
[0x7fff38ef7cb6] SetSystemUIMode +165
[0x7fff3793a9de] -[NSApplication _setPresentationOptions:instance:flags:] +1093
[0x1086d230e] qt_plugin_instance +2334
[0x1086d191e] ???
[0x10442c526] _ZN27QPlatformIntegrationFactory6createERK7QStringRK11QStringListRiPPcS2_ +198
[0x104438d59] _ZN22QGuiApplicationPrivate25createPlatformIntegrationEv +2473
[0x10443a06b] _ZN22QGuiApplicationPrivate21createEventDispatcherEv +27
[0x104b4215f] _ZN23QCoreApplicationPrivate4initEv +1567
[0x104435289] _ZN22QGuiApplicationPrivate4initEv +57
[0x103e6fa3a] _ZN19QApplicationPrivate4initEv +26
[0x1038bf5cd] _ZN21BgInherit_ApplicationCI212QApplicationERiPPci +61
[0x10383267b] _ZN21BgInherit_ApplicationCI112QApplicationERiPPci +43
[0x10383260f] bg_QApplication__CONSTRUCT_int_R_char_XX_int +95
[0x1037f4c86] *Qt::Application#initialize:Pointer(Void) +38
[0x1037f4c40] *Qt::Application::new:Qt::Application +144
[0x103778c3f] __crystal_main +1055
[0x1038002e9] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +9
[0x10380018b] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +43
[0x103784439] main +9

same backtrace when run in gdb/lldb?

libsystem memmove

isn’t c++ ?

You can use this tool (https://demangler.com).
Result is:
std::__1::__tree<CI::Node*, std::__1::less<CI::Node*>, std::__1::allocator<CI::Node*> >::destroy(std::__1::__tree_node<CI::Node*, void*>*)

1 Like

memory free problem?

Invalid memory access (signal 11) at address 0x0
[0x1037a652b] *CallStack::print_backtrace:Int32  107
[0x103789966] __crystal_sigfault_handler  262
[0x7fff71c1542d] _sigtramp  29
[0x7fff3ae8452f] std::__1::__tree<CI::Node*, std::__1::less<CI::Node*>, std::__1::allocator<CI::Node*> >::destroy(std::__1::__tree_node<CI::Node*, void*>*)  19
[0x7fff3ae84542] std::__1::__tree<CI::Node*, std::__1::less<CI::Node*>, std::__1::allocator<CI::Node*> >::destroy(std::__1::__tree_node<CI::Node*, void*>*)  38
[0x7fff3ae84536] std::__1::__tree<CI::Node*, std::__1::less<CI::Node*>, std::__1::allocator<CI::Node*> >::destroy(std::__1::__tree_node<CI::Node*, void*>*)  26
[0x7fff3ae72440] CI::Node::unique_child_count() const  114
[0x7fff3b0adb86] ___ZNK2CI11ProgramNode21compute_kernel_digestEPKNS_7ContextE_block_invoke  308
[0x7fff3b0acb28] ___ZNK2CI11ProgramNode33traverse_graph_preorder_stoppableEU13block_pointerFbPNS_4NodeES2_iiiE_block_invoke  127
[0x7fff3ae5d0fb] CI::GraphObject::traverse_preorder_stoppable(CI::GraphObject*, CI::GraphObject*, int, int, bool ( block_pointer)(CI::GraphObject*, CI::GraphObject*, int, int))  219
[0x7fff3ae722fa] CI::ProgramNode::traverse_graph_preorder_stoppable(bool ( block_pointer)(CI::Node*, CI::Node*, int, int, int)) const  138
[0x7fff3ae7218d] CI::ProgramNode::compute_kernel_digest(CI::Context const*) const  171
[0x7fff3ae71e16] CI::ProgramNode::create_program_and_arguments(CI::Context*, char const*)  526
[0x7fff3ae5bcbc] CI::GraphObject::traverse_unique(CI::GraphObject*, void ( block_pointer)(CI::GraphObject*, CI::GraphObject*, int, int, int))  220
[0x7fff3ae696b0] CI::recursive_tile(CI::RenderTask*, CI::Context*, CI::RenderDestination const*, char const*, CI::Node*, CGRect const&, CI::PixelFormat, CI::swizzle_info const&, CI::TileTask* ( block_pointer)(CI::ProgramNode*, CGRect))  1175
[0x7fff3ae68e1d] CI::tile_node_graph(CI::Context*, CI::RenderDestination const*, char const*, CI::Node*, CGRect const&, CI::PixelFormat, CI::swizzle_info const&, CI::TileTask* ( block_pointer)(CI::ProgramNode*, CGRect))  475
[0x7fff3ae68953] CI::image_get_bitmap(CI::Context*, CI::Image*, CGRect, CGColorSpace*, CI::Bitmap*, CI::RenderDestination const*)  1939
[0x7fff3ae68165] CI::RenderToBitmap::render(CI::Image*, CI::Context*) const  451
[0x7fff3ae67a39] -[CIContext(CIRenderDestination) _startTaskToRender:toDestination:forPrepareRender:forClear:error:]  3699
[0x7fff3ae66bbf] -[CIContext(CIRenderDestination) startTaskToRender:toDestination:error:]  31
[0x7fff3ae6691f] -[CIContext(CIRenderDestination) startTaskToRender:fromRect:toDestination:atPoint:error:]  190
[0x7fff3ae57496] -[CIContext(createCGImage) _createCGImage:fromRect:format:colorSpace:deferred:]  4062
[0x7fff5351ff40] CUIRenderer::CreateImageByApplyingEffectsToImage(CUIDescriptor const*, long, __CFArray const*, CGImage*, double, unsigned char, unsigned char, CGBlendMode&, bool) const  14324
[0x7fff5351b723] CUIRenderer::CreateImage(CGRect, long, CUIDescriptor const*, unsigned char, CGImage**, long long*, unsigned char*, CGBlendMode*) const  5589
[0x7fff53519e85] CUIRenderer::DrawImage(CGRect, long, CUIDescriptor const*) const  147
[0x7fff5351944f] CUICoreThemeRenderer::DrawMenuTitle(CUIDescriptor const*, CUIReturnInfo&)  813
[0x7fff53518565] CUIRenderer::Draw(CGRect, CGContext*, __CFDictionary const*, __CFDictionary const**)  1785
[0x7fff53517e3a] CUIDraw  278
[0x7fff38f100c2] _HIThemeCUIDrawWithOptions  107
[0x7fff38f1003c] _HIThemeCUIDrawWithRenderer  173
[0x7fff38f0f3b4] _HIThemeDrawAppleMenuTitle  510
[0x7fff38f0ba1d] HIMenuBarView::DrawOnce(CGRect, CGRect, bool, bool, CGContext*)  1089
[0x7fff38f0b56d] HIMenuBarView::DrawSelf(short, __HIShape const*, CGContext*)  689
[0x7fff38f0af3e] HIMenuBarView::DrawWithoutCustomization(short, __HIShape const*, CGContext*)  82
[0x7fff38f0aed6] HIMenuBarView::DrawingDelegateHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*)  258
[0x7fff38eef711] DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*)  1419
[0x7fff38eeeae0] SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*)  338
[0x7fff38eee983] SendEventToEventTargetWithOptions  45
[0x7fff38f0aa4b] HIView::SendDraw(short, OpaqueGrafPtr*, __HIShape const*, CGContext*)  325
[0x7fff38f0a4be] HIView::RecursiveDrawComposited(__HIShape const*, __HIShape const*, unsigned int, HIView*, CGContext*, unsigned char, double)  582
[0x7fff38f0a709] HIView::RecursiveDrawComposited(__HIShape const*, __HIShape const*, unsigned int, HIView*, CGContext*, unsigned char, double)  1169
[0x7fff38f09ef9] HIView::DrawComposited(short, OpaqueGrafPtr*, __HIShape const*, unsigned int, HIView*, CGContext*)  815
[0x7fff38f09bbb] HIView::Render(unsigned int, CGContext*)  51
[0x7fff38f092e9] WindowData::PrepareForVisibility()  153
[0x7fff38f5f464] _ShowHideWindows  286
[0x7fff38f08d30] ShowHide  35
[0x7fff38ef8f0b] MBWindows::GetWindowOnDisplay(unsigned int, unsigned char)  289
[0x7fff38ef8cef] MenuBarInstance::ForEachWindowDo(unsigned char, bool ( block_pointer)(OpaqueWindowPtr*, unsigned int))  183
[0x7fff38ef8bef] MenuBarInstance::SetBoundsAndUpdateResolution()  103
[0x7fff38ef876a] MenuBarInstance::Show(MenuBarAnimationStyle, unsigned char, unsigned char, unsigned char, unsigned char)  280
[0x7fff38ef81a1] MenuBarInstance::UpdateAggregateUIMode(MenuBarAnimationStyle, unsigned char, unsigned char, unsigned char)  805
[0x7fff38ef7daa] MenuBarInstance::ForEachMenuBarDo(void ( block_pointer)(MenuBarInstance*))  46
[0x7fff38ef7d4a] UpdateAllAggregateUIModes(MenuBarAnimationStyle, unsigned char)  126
[0x7fff38ef7cb6] SetSystemUIMode  165
[0x7fff3793a9de] -[NSApplication _setPresentationOptions:instance:flags:]  1093
[0x1086d230e] qt_plugin_instance  2334
[0x1086d191e] ???
[0x10442c526] QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&)  198
[0x104438d59] QGuiApplicationPrivate::createPlatformIntegration()  2473
[0x10443a06b] QGuiApplicationPrivate::createEventDispatcher()  27
[0x104b4215f] QCoreApplicationPrivate::init()  1567
[0x104435289] QGuiApplicationPrivate::init()  57
[0x103e6fa3a] QApplicationPrivate::init()  26
[0x1038bf5cd] BgInherit_Application::QApplication(int&, char**, int)  61
[0x10383267b] BgInherit_Application::QApplication(int&, char**, int)  43
[0x10383260f] bg_QApplication__CONSTRUCT_int_R_char_XX_int  95
[0x1037f4c86] *Qt::Application#initialize:Pointer(Void)  38
[0x1037f4c40] *Qt::Application::new:Qt::Application  144
[0x103778c3f] __crystal_main  1055
[0x1038002e9] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil  9
[0x10380018b] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32  43
[0x103784439] main  9

Possibly.
Or may be wrong pointer type between Crystal and underlaying library.

Premature GC? Also you could file a github issue maybe crystal should demangle those backtrace names…