<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>315577</bug_id>
          
          <creation_ts>2026-05-26 10:36:23 -0700</creation_ts>
          <short_desc>[GTK] Memory corruption when destroying DRMDeviceManager in exit handler</short_desc>
          <delta_ts>2026-06-16 15:51:40 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=2464924</see_also>
    
    <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=2481565</see_also>
    
    <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=2480975</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=305909</see_also>
    
    <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=2478138</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2214155</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2026-05-26 10:36:23 -0700</bug_when>
    <thetext>This is related to bug #305909. We have several reports of memory corruption in an exit handler, when destroying the DRMDeviceManager. We ought to use NeverDestroyed to avoid this.

Here is the simplest such stack trace. Some of them are more complicated, but all occur under WebCore::GBMDevice::~GBMDevice:

Thread 1 (Thread 0x7fa179b69680 (LWP 2)):
#0  0x00007fa184685377 in unlink_chunk (p=0x561035562aa0, av=0x7fa1847f6ac0 &lt;main_arena&gt;) at malloc.c:1591
        fd = 0x561035564a00
        bk = 0x561000000002
#1  0x00007fa1846854a8 in _int_free_create_chunk (av=av@entry=0x7fa1847f6ac0 &lt;main_arena&gt;, p=p@entry=0x561035560450, size=size@entry=9808, nextchunk=&lt;optimized out&gt;, nextsize=7952) at malloc.c:4375
        nextinuse = &lt;optimized out&gt;
        bck = &lt;optimized out&gt;
        fwd = &lt;optimized out&gt;
#2  0x00007fa184686636 in _int_free_merge_chunk (av=0x7fa1847f6ac0 &lt;main_arena&gt;, p=0x561035560450, size=9808) at malloc.c:4354
        nextchunk = &lt;optimized out&gt;
        nextsize = &lt;optimized out&gt;
#3  0x00007fa184686794 in _int_free_chunk (av=0x7fa1847f6ac0 &lt;main_arena&gt;, p=&lt;optimized out&gt;, size=&lt;optimized out&gt;, have_lock=&lt;optimized out&gt;, have_lock@entry=0) at malloc.c:4278
        err = 0
#4  0x00007fa184689356 in __GI___libc_free (mem=&lt;optimized out&gt;) at malloc.c:3353
        p = &lt;optimized out&gt;
        size = &lt;optimized out&gt;
#5  0x00007fa11c1d0288 in dri_destroy (gbm=0x561035435f20) at ../src/gbm/backends/dri/gbm_dri.c:1183
        dri = 0x561035435f20
        i = &lt;optimized out&gt;
#6  0x00007fa17ff0c714 in _gbm_device_destroy (gbm=&lt;optimized out&gt;) at ../src/gbm/main/backend.c:171
        backend_desc = 0x5610353eba90
#7  0x00007fa184bc284c in WebCore::GBMDevice::~GBMDevice (this=0x7fa16f000b90) at /usr/src/debug/webkitgtk-2.52.3-1.fc45.x86_64/Source/WebCore/platform/graphics/gbm/GBMDevice.cpp:63
#8  WTF::ThreadSafeRefCounted&lt;WebCore::GBMDevice, (WTF::DestructionThread)1&gt;::deref() const::{lambda()#1}::operator()() const (this=&lt;optimized out&gt;) at WTF/Headers/wtf/ThreadSafeRefCounted.h:102
#9  WTF::Detail::CallableWrapper&lt;WTF::ThreadSafeRefCounted&lt;WebCore::GBMDevice, (WTF::DestructionThread)1&gt;::deref() const::{lambda()#1}, void&gt;::call() (this=&lt;optimized out&gt;) at WTF/Headers/wtf/Function.h:59
#10 0x00007fa187685448 in WTF::ThreadSafeRefCounted&lt;WebCore::GBMDevice, (WTF::DestructionThread)1&gt;::deref (this=0x7fa16f000b90) at WTF/Headers/wtf/ThreadSafeRefCounted.h:101
#11 WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt;::derefIfNotNull (ptr=0x7fa16f000b90) at WTF/Headers/wtf/Ref.h:64
#12 WTF::RefPtr&lt;WebCore::GBMDevice, WTF::RawPtrTraits&lt;WebCore::GBMDevice&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt; &gt;::~RefPtr (this=0x7fa16f01c328) at WTF/Headers/wtf/RefPtr.h:66
#13 std::_Optional_payload_base&lt;WTF::RefPtr&lt;WebCore::GBMDevice, WTF::RawPtrTraits&lt;WebCore::GBMDevice&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt; &gt; &gt;::_M_destroy (this=0x7fa16f01c328) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/optional:323
#14 std::_Optional_payload_base&lt;WTF::RefPtr&lt;WebCore::GBMDevice, WTF::RawPtrTraits&lt;WebCore::GBMDevice&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt; &gt; &gt;::_M_reset (this=0x7fa16f01c328) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/optional:354
#15 std::_Optional_payload&lt;WTF::RefPtr&lt;WebCore::GBMDevice, WTF::RawPtrTraits&lt;WebCore::GBMDevice&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt; &gt;, false, false, false&gt;::~_Optional_payload (this=0x7fa16f01c328) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/optional:477
#16 std::_Optional_base&lt;WTF::RefPtr&lt;WebCore::GBMDevice, WTF::RawPtrTraits&lt;WebCore::GBMDevice&gt;, WTF::DefaultRefDerefTraits&lt;WebCore::GBMDevice&gt; &gt;, false, false&gt;::~_Optional_base (this=0x7fa16f01c328) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/optional:501
#17 WebCore::DRMDeviceManager::{unnamed type#1}::~DRMDeviceManager() (this=0x7fa16f01c300) at /usr/src/debug/webkitgtk-2.52.3-1.fc45.x86_64/Source/WebCore/platform/graphics/gbm/DRMDeviceManager.h:55
#18 0x00007fa18768532e in WebCore::DRMDeviceManager::~DRMDeviceManager (this=0x7fa16f01c300) at /usr/src/debug/webkitgtk-2.52.3-1.fc45.x86_64/Source/WebCore/platform/graphics/gbm/DRMDeviceManager.cpp:44
#19 std::default_delete&lt;WebCore::DRMDeviceManager&gt;::operator() (this=0x7fa189da3768 &lt;_ZZN7WebCore16DRMDeviceManager9singletonEvE9s_manager.llvm.12492648584019885231&gt;, __ptr=0x7fa16f01c300) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/bits/unique_ptr.h:92
#20 std::unique_ptr&lt;WebCore::DRMDeviceManager, std::default_delete&lt;WebCore::DRMDeviceManager&gt; &gt;::~unique_ptr (this=0x7fa189da3768 &lt;_ZZN7WebCore16DRMDeviceManager9singletonEvE9s_manager.llvm.12492648584019885231&gt;) at /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../include/c++/16/bits/unique_ptr.h:398
        __ptr = @0x7fa189da3768: 0x7fa16f01c300
#21 0x00007fa184621d81 in __run_exit_handlers (status=0, listp=0x7fa1847f6680 &lt;__exit_funcs&gt;, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:118
        atfct = &lt;optimized out&gt;
        onfct = &lt;optimized out&gt;
        cxafct = &lt;optimized out&gt;
        arg = &lt;optimized out&gt;
        f = &lt;optimized out&gt;
        new_exitfn_called = 2804
        cur = 0x7fa1847f7fa0 &lt;initial&gt;
#22 0x00007fa184621e5e in __GI_exit (status=&lt;optimized out&gt;) at exit.c:148
#23 0x00007fa184608688 in __libc_start_call_main (main=main@entry=0x5610307134a0 &lt;main(int, char**)&gt;, argc=argc@entry=3, argv=argv@entry=0x7ffcc92bfaa8) at ../sysdeps/nptl/libc_start_call_main.h:83
        result = &lt;optimized out&gt;
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -4672943008369691645, 140723683588776, 3, 140331781521440, 94627532201312, -4672943008323554301, -4639616356607544317}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x7ffcc92bfaa8}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = &lt;optimized out&gt;
#24 0x00007fa184608798 in __libc_start_main_impl (main=0x5610307134a0 &lt;main(int, char**)&gt;, argc=3, argv=0x7ffcc92bfaa8, init=&lt;optimized out&gt;, fini=&lt;optimized out&gt;, rtld_fini=&lt;optimized out&gt;, stack_end=0x7ffcc92bfa98) at ../csu/libc-start.c:360
#25 0x00005610307133d5 in _start ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2214763</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2026-05-26 16:49:05 -0700</bug_when>
    <thetext>One user reports:

&quot;&quot;&quot;
I just closed Proton Authenticator application (installed from file ProtonAuthenticator-1.1.5-1.x86_64.rpm) and it shows an error. Application closed normally from my perspective.
It does not do this all the time i close this application. Instead, the way to reproduce the crash is this:
- open the app, resize it, move it to another monitor, close the app.
&quot;&quot;&quot;

I don&apos;t have a spare monitor, so I haven&apos;t tested this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2221388</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2026-06-16 15:51:08 -0700</bug_when>
    <thetext>I found a reproducer, but it&apos;s not one that I can share. :( Loading a particular email in an experimental nonpublic email client triggers a UI process crash, and then this web process crash occurs consequently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2221389</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2026-06-16 15:51:40 -0700</bug_when>
    <thetext>(The UI process crash is an application bug, not a WebKit bug.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>