<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>276224</bug_id>
          
          <creation_ts>2024-07-04 06:55:39 -0700</creation_ts>
          <short_desc>[GStreamer] gstStructureGet&lt;T&gt; may return optionals with unitialized values on Clang 18</short_desc>
          <delta_ts>2024-07-04 11:54:14 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Carlos Bentzen">cadubentzen</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>philn</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2044675</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Bentzen">cadubentzen</who>
    <bug_when>2024-07-04 06:55:39 -0700</bug_when>
    <thetext>On bug 275609 we introduced the gstStructureGet&lt;T&gt; 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 &quot;a-structure, width=10&quot;. If we try:

auto height = gstStructureGet&lt;int&gt;(structure, &quot;height&quot;_s);
if (height)
    GST_LOG(&quot;height = %d&quot;, *height);

although the branch shouldn&apos;t be executed since there&apos;s no &quot;height&quot; field. It is executed with an unitialized value.

After debugging what&apos;s happening, it seems to be actually a compiler issue. Fixed it by using if(UNLIKELY(gst_structure_get_&lt;type&gt;)) in gstStructureGet branches. Without that, the branches were being executed and returning std::optional with unitialized values when they shouldn&apos;t.

Patch for the fix in WebKit incoming. Pending on a minimal reproducer outside WebKit to confirm it&apos;s a bug in Clang...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2044682</commentid>
    <comment_count>1</comment_count>
    <who name="Philippe Normand">philn</who>
    <bug_when>2024-07-04 07:27:32 -0700</bug_when>
    <thetext>*** Bug 276222 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2044688</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Bentzen">cadubentzen</who>
    <bug_when>2024-07-04 08:54:02 -0700</bug_when>
    <thetext>Reduced the copmpiler bug outside of WebKit at https://github.com/cadubentzen/std-optional-bug-clang</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2044692</commentid>
    <comment_count>3</comment_count>
    <who name="Carlos Bentzen">cadubentzen</who>
    <bug_when>2024-07-04 09:32:12 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/30493</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2044717</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-07-04 11:53:24 -0700</bug_when>
    <thetext>Committed 280669@main (98b041523464): &lt;https://commits.webkit.org/280669@main&gt;

Reviewed commits have been landed. Closing PR #30493 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2044718</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-07-04 11:54:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/131130985&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>