Both MALLOC_CHECK_ and valgrind agree on the cause of the crash. The nested server is trying to set up and then destroy real DRM resources (which it should not, because it's a nested server):
==29944== Invalid free() / delete / delete[] / realloc()
==29944== at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29944== by 0x937F228: ??? (in /usr/lib/x86_64-linux-gnu/libgbm.so.1.0.0)
==29944== by 0xB2F77F0: mir::graphics::mesa::helpers::GBMHelper::~GBMHelper() (display_helpers.cpp:292)
==29944== by 0xB31EC50: mir::graphics::mesa::NativePlatform::~NativePlatform() (native_platform.cpp:51)
==29944== by 0xB322C98: void __gnu_cxx::new_allocator<mir::graphics::mesa::NativePlatform>::destroy<mir::graphics::mesa::NativePlatform>(mir::graphics::mesa::NativePlatform*) (new_allocator.h:124)
==29944== by 0xB322C4A: std::enable_if<std::__and_<std::allocator_traits<std::allocator<mir::graphics::mesa::NativePlatform> >::__destroy_helper<mir::graphics::mesa::NativePlatform>::type>::value, void>::type std::allocator_traits<std::allocator<mir::graphics::mesa::NativePlatform> >::_S_destroy<mir::graphics::mesa::NativePlatform>(std::allocator<mir::graphics::mesa::NativePlatform>&, mir::graphics::mesa::NativePlatform*) (alloc_traits.h:282)
==29944== by 0xB322BF2: void std::allocator_traits<std::allocator<mir::graphics::mesa::NativePlatform> >::destroy<mir::graphics::mesa::NativePlatform>(std::allocator<mir::graphics::mesa::NativePlatform>&, mir::graphics::mesa::NativePlatform*) (alloc_traits.h:411)
==29944== by 0xB322AE4: std::_Sp_counted_ptr_inplace<mir::graphics::mesa::NativePlatform, std::allocator<mir::graphics::mesa::NativePlatform>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:524)
==29944== by 0x4E81CDF: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==29944== by 0x4E81A48: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:666)
==29944== by 0x4F96393: std::__shared_ptr<mir::graphics::NativePlatform, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:914)
==29944== by 0x4F963AD: std::shared_ptr<mir::graphics::NativePlatform>::~shared_ptr() (shared_ptr.h:93)
==29944== Address 0xab3cb60 is 0 bytes inside a block of size 5 free'd
==29944== at 0x4C2BE10: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29944== by 0x714518D: ??? (in /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so.1.0.0)
==29944== by 0x713C551: eglTerminate (in /usr/lib/x86_64-linux-gnu/mesa-egl/libEGL.so.1.0.0)
==29944== by 0x50211E4: mir::graphics::nested::detail::EGLDisplayHandle::~EGLDisplayHandle() (nested_display.cpp:119)
==29944== by 0x5021513: mir::graphics::nested::NestedDisplay::~NestedDisplay() (nested_display.cpp:141)
==29944== by 0x502DBA4: void __gnu_cxx::new_allocator<mir::graphics::nested::NestedDisplay>::destroy<mir::graphics::nested::NestedDisplay>(mir::graphics::nested::NestedDisplay*) (new_allocator.h:124)
==29944== by 0x502DB56: std::enable_if<std::__and_<std::allocator_traits<std::allocator<mir::graphics::nested::NestedDisplay> >::__destroy_helper<mir::graphics::nested::NestedDisplay>::type>::value, void>::type std::allocator_traits<std::allocator<mir::graphics::nested::NestedDisplay> >::_S_destroy<mir::graphics::nested::NestedDisplay>(std::allocator<mir::graphics::nested::NestedDisplay>&, mir::graphics::nested::NestedDisplay*) (alloc_traits.h:282)
==29944== by 0x502DAFE: void std::allocator_traits<std::allocator<mir::graphics::nested::NestedDisplay> >::destroy<mir::graphics::nested::NestedDisplay>(std::allocator<mir::graphics::nested::NestedDisplay>&, mir::graphics::nested::NestedDisplay*) (alloc_traits.h:411)
==29944== by 0x502D9F0: std::_Sp_counted_ptr_inplace<mir::graphics::nested::NestedDisplay, std::allocator<mir::graphics::nested::NestedDisplay>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:524)
==29944== by 0x4E81CDF: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==29944== by 0x4E81A48: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:666)
==29944== by 0x4E85D79: std::__shared_ptr<mir::graphics::Display, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:914
Both MALLOC_CHECK_ and valgrind agree on the cause of the crash. The nested server is trying to set up and then destroy real DRM resources (which it should not, because it's a nested server):
==29944== Invalid free() / delete / delete[] / realloc() valgrind/ vgpreload_ memcheck- amd64-linux. so) x86_64- linux-gnu/ libgbm. so.1.0. 0) :mesa:: helpers: :GBMHelper: :~GBMHelper( ) (display_ helpers. cpp:292) :mesa:: NativePlatform: :~NativePlatfor m() (native_ platform. cpp:51) :new_allocator< mir::graphics: :mesa:: NativePlatform> ::destroy< mir::graphics: :mesa:: NativePlatform> (mir::graphics: :mesa:: NativePlatform* ) (new_allocator. h:124) if<std: :__and_ <std::allocator _traits< std::allocator< mir::graphics: :mesa:: NativePlatform> >::__destroy_ helper< mir::graphics: :mesa:: NativePlatform> ::type> ::value, void>::type std::allocator_ traits< std::allocator< mir::graphics: :mesa:: NativePlatform> >::_S_destroy< mir::graphics: :mesa:: NativePlatform> (std::allocator <mir::graphics: :mesa:: NativePlatform> &, mir::graphics: :mesa:: NativePlatform* ) (alloc_ traits. h:282) traits< std::allocator< mir::graphics: :mesa:: NativePlatform> >::destroy< mir::graphics: :mesa:: NativePlatform> (std::allocator <mir::graphics: :mesa:: NativePlatform> &, mir::graphics: :mesa:: NativePlatform* ) (alloc_ traits. h:411) counted_ ptr_inplace< mir::graphics: :mesa:: NativePlatform, std::allocator< mir::graphics: :mesa:: NativePlatform> , (__gnu_ cxx::_Lock_ policy) 2>::_M_ dispose( ) (shared_ ptr_base. h:524) counted_ base<(_ _gnu_cxx: :_Lock_ policy) 2>::_M_ release( ) (shared_ ptr_base. h:149) shared_ count<( __gnu_cxx: :_Lock_ policy) 2>::~__ shared_ count() (shared_ ptr_base. h:666) shared_ ptr<mir: :graphics: :NativePlatform , (__gnu_ cxx::_Lock_ policy) 2>::~__ shared_ ptr() (shared_ ptr_base. h:914) ptr<mir: :graphics: :NativePlatform >::~shared_ ptr() (shared_ptr.h:93) valgrind/ vgpreload_ memcheck- amd64-linux. so) x86_64- linux-gnu/ mesa-egl/ libEGL. so.1.0. 0) x86_64- linux-gnu/ mesa-egl/ libEGL. so.1.0. 0) :nested: :detail: :EGLDisplayHand le::~EGLDisplay Handle( ) (nested_ display. cpp:119) :nested: :NestedDisplay: :~NestedDisplay () (nested_ display. cpp:141) :new_allocator< mir::graphics: :nested: :NestedDisplay> ::destroy< mir::graphics: :nested: :NestedDisplay> (mir::graphics: :nested: :NestedDisplay* ) (new_allocator. h:124) if<std: :__and_ <std::allocator _traits< std::allocator< mir::graphics: :nested: :NestedDisplay> >::__destroy_ helper< mir::graphics: :nested: :NestedDisplay> ::type> ::value, void>::type std::allocator_ traits< std::allocator< mir::graphics: :nested: :NestedDisplay> >::_S_destroy< mir::graphics: :nested: :NestedDisplay> (std::allocator <mir::graphics: :nested: :NestedDisplay> &, mir::graphics: :nested: :NestedDisplay* ) (alloc_ traits. h:282) traits< std::allocator< mir::graphics: :nested: :NestedDisplay> >::destroy< mir::graphics: :nested: :NestedDisplay> (std::allocator <mir::graphics: :nested: :NestedDisplay> &, mir::graphics: :nested: :NestedDisplay* ) (alloc_ traits. h:411) counted_ ptr_inplace< mir::graphics: :nested: :NestedDisplay, std::allocator< mir::graphics: :nested: :NestedDisplay> , (__gnu_ cxx::_Lock_ policy) 2>::_M_ dispose( ) (shared_ ptr_base. h:524) counted_ base<(_ _gnu_cxx: :_Lock_ policy) 2>::_M_ release( ) (shared_ ptr_base. h:149) shared_ count<( __gnu_cxx: :_Lock_ policy) 2>::~__ shared_ count() (shared_ ptr_base. h:666) shared_ ptr<mir: :graphics: :Display, (__gnu_ cxx::_Lock_ policy) 2>::~__ shared_ ptr() (shared_ ptr_base. h:914
==29944== at 0x4C2BE10: free (in /usr/lib/
==29944== by 0x937F228: ??? (in /usr/lib/
==29944== by 0xB2F77F0: mir::graphics:
==29944== by 0xB31EC50: mir::graphics:
==29944== by 0xB322C98: void __gnu_cxx:
==29944== by 0xB322C4A: std::enable_
==29944== by 0xB322BF2: void std::allocator_
==29944== by 0xB322AE4: std::_Sp_
==29944== by 0x4E81CDF: std::_Sp_
==29944== by 0x4E81A48: std::__
==29944== by 0x4F96393: std::__
==29944== by 0x4F963AD: std::shared_
==29944== Address 0xab3cb60 is 0 bytes inside a block of size 5 free'd
==29944== at 0x4C2BE10: free (in /usr/lib/
==29944== by 0x714518D: ??? (in /usr/lib/
==29944== by 0x713C551: eglTerminate (in /usr/lib/
==29944== by 0x50211E4: mir::graphics:
==29944== by 0x5021513: mir::graphics:
==29944== by 0x502DBA4: void __gnu_cxx:
==29944== by 0x502DB56: std::enable_
==29944== by 0x502DAFE: void std::allocator_
==29944== by 0x502D9F0: std::_Sp_
==29944== by 0x4E81CDF: std::_Sp_
==29944== by 0x4E81A48: std::__
==29944== by 0x4E85D79: std::__