Bug 281989

Summary: [WPE][GTK] Clang 19 unsafe-buffer warnings
Product: WebKit Reporter: Philippe Normand <philn>
Component: WebKitGTKAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, mcatanzaro
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Philippe Normand
Reported 2024-10-23 10:22:33 PDT
[1439/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/UIProcess/Automation/skia/WebAutomationSessionSkia.cpp.o /var/home/phil/WebKit/Source/WebKit/UIProcess/Automation/skia/WebAutomationSessionSkia.cpp:51:33: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 51 | return base64EncodeToString(std::span<const uint8_t>(data->bytes(), data->size())); | ^ 1 warning generated. [1472/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/Shared/skia/WebCoreArgumentCodersSkia.cpp.o In file included from /var/home/phil/WebKit/Source/WebKit/Shared/skia/WebCoreArgumentCodersSkia.cpp:31: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkColorSpace.h:55:20: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 55 | return { m_serializedColorSpace->bytes(), m_serializedColorSpace->size() }; | ^ In file included from /var/home/phil/WebKit/Source/WebKit/Shared/skia/WebCoreArgumentCodersSkia.cpp:32: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkData.h:50:16: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 50 | return { m_skData->bytes(), m_skData->size() }; | ^ 2 warnings generated. [1583/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/WebKitPlatformGeneratedSerializers.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/WebKitPlatformGeneratedSerializers.cpp:32: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkColorSpace.h:55:20: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 55 | return { m_serializedColorSpace->bytes(), m_serializedColorSpace->size() }; | ^ In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/WebKitPlatformGeneratedSerializers.cpp:34: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkData.h:50:16: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 50 | return { m_skData->bytes(), m_skData->size() }; | ^ 2 warnings generated. [1597/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/unified-sources/UnifiedSource-123a7f2f-3.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/unified-sources/UnifiedSource-123a7f2f-3.cpp:8: In file included from /var/home/phil/WebKit/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp:32: /var/home/phil/WebKit/Source/WebKit/Platform/IPC/unix/UnixMessage.h:99:22: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 99 | m_body = std::span { static_cast<uint8_t*>(fastMalloc(m_messageInfo.bodySize())), m_messageInfo.bodySize() }; | ^ 1 warning generated. [1603/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/unified-sources/UnifiedSource-123a7f2f-1.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/unified-sources/UnifiedSource-123a7f2f-1.cpp:6: In file included from /var/home/phil/WebKit/Source/WebKit/Platform/IPC/Connection.cpp:55: /var/home/phil/WebKit/Source/WebKit/Platform/IPC/unix/UnixMessage.h:99:22: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 99 | m_body = std::span { static_cast<uint8_t*>(fastMalloc(m_messageInfo.bodySize())), m_messageInfo.bodySize() }; | ^ 1 warning generated. [1616/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/unified-sources/UnifiedSource-72468c22-9.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/unified-sources/UnifiedSource-72468c22-9.cpp:7: /var/home/phil/WebKit/Source/WebKit/NetworkProcess/cache/NetworkCacheDataGLib.cpp:68:12: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 68 | return { reinterpret_cast<const uint8_t*>(g_bytes_get_data(m_buffer.get(), nullptr)), g_bytes_get_size(m_buffer.get()) }; | ^ /var/home/phil/WebKit/Source/WebKit/NetworkProcess/cache/NetworkCacheDataGLib.cpp:88:20: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 88 | return applier({ reinterpret_cast<const uint8_t*>(data), length }); | ^ 2 warnings generated. [1623/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/SerializedTypeInfo.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/SerializedTypeInfo.cpp:78: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkColorSpace.h:55:20: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 55 | return { m_serializedColorSpace->bytes(), m_serializedColorSpace->size() }; | ^ In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/SerializedTypeInfo.cpp:83: /var/home/phil/WebKit/Source/WebKit/Shared/skia/CoreIPCSkData.h:50:16: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 50 | return { m_skData->bytes(), m_skData->size() }; | ^ 2 warnings generated. [1643/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/unified-sources/UnifiedSource-72468c22-11.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/unified-sources/UnifiedSource-72468c22-11.cpp:1: /var/home/phil/WebKit/Source/WebKit/NetworkProcess/soup/WebSocketTaskSoup.cpp:183:15: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 183 | std::span dataSpan { static_cast<const uint8_t*>(data), dataSize }; | ^ 1 warning generated. [1665/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/UIProcess/API/glib/WebKitFormSubmissionRequest.cpp.o /var/home/phil/WebKit/Source/WebKit/UIProcess/API/glib/WebKitFormSubmissionRequest.cpp:113:71: warning: unsafe buffer access [-Wunsafe-buffer-usage] 113 | GUniquePtr<char> name(g_strdup_inline (static_cast<char*>(request->priv->textFieldNames->pdata[i]))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /var/home/phil/WebKit/Source/WebKit/UIProcess/API/glib/WebKitFormSubmissionRequest.cpp:114:72: warning: unsafe buffer access [-Wunsafe-buffer-usage] 114 | GUniquePtr<char> value(g_strdup_inline (static_cast<char*>(request->priv->textFieldValues->pdata[i]))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 warnings generated. [1676/2118] Building CXX object Source/WebKit/CMakeFiles/WebKit.dir/__/__/DerivedSources/WebKit/unified-sources/UnifiedSource-50d0d8dd-21.cpp.o In file included from /var/home/phil/WebKit/WebKitBuild/GTK/Release/DerivedSources/WebKit/unified-sources/UnifiedSource-50d0d8dd-21.cpp:1: /var/home/phil/WebKit/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp:46:16: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 46 | encoder << std::span(array->data, array->len); | ^ /var/home/phil/WebKit/Source/WebKit/Shared/glib/ArgumentCodersGLib.cpp:76:16: warning: the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information [-Wunsafe-buffer-usage-in-container] 76 | encoder << std::span(static_cast<const uint8_t*>(g_variant_get_data(variant.get())), g_variant_get_size(variant.get())); | ^ 2 warnings generated.
Attachments
Philippe Normand
Comment 1 2024-10-23 10:23:30 PDT
There's more of those, I can share the log for a full build if that's useful.
Michael Catanzaro
Comment 2 2024-10-28 12:23:41 PDT
*** Bug 282193 has been marked as a duplicate of this bug. ***
Michael Catanzaro
Comment 3 2024-10-28 12:28:54 PDT
Michael Catanzaro
Comment 4 2024-10-28 12:29:52 PDT
Hopefully my pull request is enough to make the build work for you. If not, you can just add more of the warning suppression macros.
EWS
Comment 5 2024-10-28 13:41:08 PDT
Committed 285787@main (8471a1156fd6): <https://commits.webkit.org/285787@main> Reviewed commits have been landed. Closing PR #35812 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.