# ASAN reporting leaks in qtweb example

**URL:** <https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985>\
**Category:** ROOT\
**Tags:** bug, root\
**Created:** [January 27, 2024, 8:08pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985 "2024-01-27T20:08:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan0270](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@ryan0270](https://root-forum.cern.ch/u/ryan0270)\
**Post date:** [January 27, 2024, 8:08pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/1 "2024-01-27T20:08:18Z")

</div>

* * *

\_ROOT Version: 6.30.02  
\_Platform: Arch Linux (modified PKGBUILD for qt6web)  
\_Compiler: gcc 13.2

* * *

[qtweb.txt](https://root-forum.cern.ch/uploads/short-url/4RHbzAp3ELGhtTgDXgswKGy793G.txt) (752.6 KB)

I modified the qtweb example to enable the address sanitizer

```cmake
add_compile_options(-fsanitize=address,undefined,float-divide-by-zero,float-cast-overflow)
add_link_options(-fsanitize=address,undefined,float-divide-by-zero,float-cast-overflow)

```

The example runs normally but on close it’s reporting a bunch of memory leaks that look like they are related to shutting down the qt web engine (full log attached). It’s hard to say for sure if this is a problem with ROOT or with Qt, but for me these types of leaks are usually incorrect usage from the application.

```txt
Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7ffb426e2002 in operator new(unsigned long) /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x7ffb3ad19cd9 (/usr/lib/libQt6WebEngineCore.so.6+0x4719cd9) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #2 0x7ffb3ad08e59 (/usr/lib/libQt6WebEngineCore.so.6+0x4708e59) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #3 0x7ffb3ad084e7 (/usr/lib/libQt6WebEngineCore.so.6+0x47084e7) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #4 0x7ffb3ad055e9 (/usr/lib/libQt6WebEngineCore.so.6+0x47055e9) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #5 0x7ffb3af53fa7 (/usr/lib/libQt6WebEngineCore.so.6+0x4953fa7) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #6 0x7ffb3af54000 (/usr/lib/libQt6WebEngineCore.so.6+0x4954000) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #7 0x7ffb396ebd97 (/usr/lib/libQt6WebEngineCore.so.6+0x30ebd97) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #8 0x7ffb396ebea0 (/usr/lib/libQt6WebEngineCore.so.6+0x30ebea0) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #9 0x7ffb396f0c7c (/usr/lib/libQt6WebEngineCore.so.6+0x30f0c7c) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #10 0x7ffb396f0e04 (/usr/lib/libQt6WebEngineCore.so.6+0x30f0e04) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #11 0x7ffb396f0e20 (/usr/lib/libQt6WebEngineCore.so.6+0x30f0e20) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #12 0x7ffb3722f5af (/usr/lib/libQt6WebEngineCore.so.6+0xc2f5af) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #13 0x7ffb3722f70f (/usr/lib/libQt6WebEngineCore.so.6+0xc2f70f) (BuildId: b27bcadd36d1e331dd4fa0e384417ff92b0f7135)
    #14 0x7ffb33f617b1 in qt_call_post_routines() (/usr/lib/libQt6Core.so.6+0x1617b1) (BuildId: cb022489bffbb1eff08dc837c4e1efc95941a304)

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [January 27, 2024, 8:35pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/2 "2024-01-27T20:35:10Z")

</div>

Thanks for reporting this, I hope @linev can take a look

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [January 29, 2024, 8:11am UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/3 "2024-01-29T08:11:46Z")

</div>

Hi,

There are several objects in qt5web plugin which are intentionally not deleted.  
On some platforms I see crashes during shutdown if trying to delete them.  
I do not think it is important - especially for application shutdown.

If interesting, [here they are](https://github.com/root-project/root/blob/master/gui/qt5webdisplay/rootqt5.cpp#L106-L115).

But I expect much more objects in `QWebEngine` which cannot be correctly cleaned up.

---

<div class="post-metadata">

**Author:** ![ryan0270](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@ryan0270](https://root-forum.cern.ch/u/ryan0270)\
**Post date:** [January 30, 2024, 1:14pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/4 "2024-01-30T13:14:15Z")

</div>

That is a disappointing answer in the context of production quality software. Shutdown leaks are absolutely a problem

- I’m using the sanitizer to find leaks in my own software but now I need to filter through thousands of lines of unrelated leaks
- I can’t use the sanitizer during automated testing b/c the exit code is non-zero when leaks are found
- Lack of destruction means Qt6WebEngineCore is not cleaning up it’s resources. Some will be automatically reclaimed by the OS but no guarantee that everything is.
- It seems unlikely that Qt has designed this to leak on exit, which means ROOT is in some way not using it correctly. What else is it not using correctly? When I have strange behavior in the future how will I know if it’s something I’m doing wrong or due to this incorrect usage within ROOT?

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [January 30, 2024, 1:56pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/5 "2024-01-30T13:56:57Z")

</div>

I have no idea that can be done here.

When ROOT objects are deleted during application shutdown - Qt seems to be uses objects which were created in qt5web plugin. Trying to delete them directly leads to crash or hanging of the application.

There is [QObject::deleteLater()](https://doc.qt.io/qt-6/qobject.html#deleteLater) method which potentially can be used for delayed cleanup. But it is useless when application loop is no longer running.

And I pretty sure that `QWebEngine` itself not able to correctly cleanup all objects it created.

Therefore the only solution for now - creating custom rules for sanitizer.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 13, 2024, 1:57pm UTC](https://root-forum.cern.ch/t/asan-reporting-leaks-in-qtweb-example/57985/6 "2024-02-13T13:57:58Z")

</div>

Closed on February 13, 2024, 1:57pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
