Bug 309978

Summary: [WPE][GTK] unsafe-buffer-usage-in-format-attr-call clang-22 warnings
Product: WebKit Reporter: Philippe Normand <philn>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: aperez, bugs-noreply, mcatanzaro
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 314914    
Bug Blocks:    

Philippe Normand
Reported 2026-03-15 02:36:17 PDT
With clang-22 a bunch of those are raised, example: In file included from /var/home/phil/WebKit/Source/WTF/wtf/SystemTracing.h:207: /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:54:9: warning: formatting function 'sysprof_collector_mark_vprintf' is unsafe [-Wunsafe-buffer-usage-in-format-attr-call] 54 | sysprof_collector_mark_vprintf((sysprof_clock_get_current_time()), 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:54:107: note: string argument is not guaranteed to be null-terminated 54 | sysprof_collector_mark_vprintf((sysprof_clock_get_current_time()), 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:62:9: warning: formatting function 'sysprof_collector_mark_vprintf' is unsafe [-Wunsafe-buffer-usage-in-format-attr-call] 62 | sysprof_collector_mark_vprintf(time, 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:62:77: note: string argument is not guaranteed to be null-terminated 62 | sysprof_collector_mark_vprintf(time, 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:104:13: warning: formatting function 'sysprof_collector_mark_vprintf' is unsafe [-Wunsafe-buffer-usage-in-format-attr-call] 104 | sysprof_collector_mark_vprintf((sysprof_clock_get_current_time()), 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/SysprofAnnotator.h:104:111: note: string argument is not guaranteed to be null-terminated 104 | sysprof_collector_mark_vprintf((sysprof_clock_get_current_time()), 0, m_processName, name.data(), description, args); | ^~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/RunLoopGLib.cpp:108:75: warning: formatting function 'instantMark' is unsafe [-Wunsafe-buffer-usage-in-format-attr-call] 108 | if (auto* annotator = SysprofAnnotator::singletonIfCreated()) annotator->instantMark(std::span("RunLoopSourceDispatch"), "" "[%s] lateness=%ldµs", g_source_get_name(source), lateness); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/home/phil/WebKit/Source/WTF/wtf/glib/RunLoopGLib.cpp:108:161: note: string argument is not guaranteed to be null-terminated 108 | if (auto* annotator = SysprofAnnotator::singletonIfCreated()) annotator->instantMark(std::span("RunLoopSourceDispatch"), "" "[%s] lateness=%ldµs", g_source_get_name(source), lateness); | ^~~~~~~~~~~~~~~~~~~~~~~~~ 4 warnings generated.
Attachments
Philippe Normand
Comment 1 2026-03-15 02:57:58 PDT
What should we do? Add -Wno-unsafe-buffer-usage-in-format-attr-call in 3 CMakeLists.txt files or sprinkle hundreds of WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN/END calls all over the place?
Adrian Perez
Comment 2 2026-03-16 02:45:13 PDT
(In reply to Philippe Normand from comment #1) > What should we do? Add -Wno-unsafe-buffer-usage-in-format-attr-call in 3 > CMakeLists.txt files or sprinkle hundreds of > WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN/END calls all over the place? I would add the suppression macro covering the whole file, and later we can figure out how to placate the warnings. Same as we did when initially adding the first compiler flags for unsafe buffer warnings: suppress first, progressively burn them down later.
Philippe Normand
Comment 3 2026-03-16 03:58:54 PDT
But these happen in quite a few third-party dependencies, I'm not sure we can fix those. And also GST_DEBUG is used in dozens of our files :( Is this warning really useful?
Adrian Perez
Comment 4 2026-03-16 04:11:31 PDT
(In reply to Philippe Normand from comment #3) > But these happen in quite a few third-party dependencies, I'm not sure we > can fix those. And also GST_DEBUG is used in dozens of our files :( > > Is this warning really useful? We have WTF_IGNORE_WARNINGS_IN_THIRD_PARTY_CODE_{BEGIN,END} for those cases. We add those markers before and after including the header(s) that define the problematic functions/macros -- we use this for Skia headers in a number of sources.
Philippe Normand
Comment 5 2026-05-16 00:45:00 PDT
*** This bug has been marked as a duplicate of bug 314914 ***
Note You need to log in before you can comment on or make changes to this bug.