Bug 276224
| Summary: | [GStreamer] gstStructureGet<T> may return optionals with unitialized values on Clang 18 | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Carlos Bentzen <cadubentzen> |
| Component: | Platform | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | bugs-noreply, philn, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Carlos Bentzen
On bug 275609 we introduced the gstStructureGet<T> helper. After using it in more places, we found what may be a compiler bug (reproduced it with Clang 18 so far).
Given a GstStructure named structure with "a-structure, width=10". If we try:
auto height = gstStructureGet<int>(structure, "height"_s);
if (height)
GST_LOG("height = %d", *height);
although the branch shouldn't be executed since there's no "height" field. It is executed with an unitialized value.
After debugging what's happening, it seems to be actually a compiler issue. Fixed it by using if(UNLIKELY(gst_structure_get_<type>)) in gstStructureGet branches. Without that, the branches were being executed and returning std::optional with unitialized values when they shouldn't.
Patch for the fix in WebKit incoming. Pending on a minimal reproducer outside WebKit to confirm it's a bug in Clang...
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Philippe Normand
*** Bug 276222 has been marked as a duplicate of this bug. ***
Carlos Bentzen
Reduced the copmpiler bug outside of WebKit at https://github.com/cadubentzen/std-optional-bug-clang
Carlos Bentzen
Pull request: https://github.com/WebKit/WebKit/pull/30493
EWS
Committed 280669@main (98b041523464): <https://commits.webkit.org/280669@main>
Reviewed commits have been landed. Closing PR #30493 and removing active labels.
Radar WebKit Bug Importer
<rdar://problem/131130985>