ASAN reporting leaks in qtweb example


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


qtweb.txt (752.6 KB)

I modified the qtweb example to enable the address sanitizer

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.

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)

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

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.

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

1 Like

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?

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() 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.

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