<?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>282396</bug_id>
          
          <creation_ts>2024-10-31 10:53:35 -0700</creation_ts>
          <short_desc>Usage of AtomString in TrackPrivateBaseGStreamer is not thread-safe</short_desc>
          <delta_ts>2024-11-08 01:16:54 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alicia Boya García">aboya</reporter>
          <assigned_to name="Alicia Boya García">aboya</assigned_to>
          <cc>bugs-noreply</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2071909</commentid>
    <comment_count>0</comment_count>
    <who name="Alicia Boya García">aboya</who>
    <bug_when>2024-10-31 10:53:35 -0700</bug_when>
    <thetext>Currently TrackPrivateBaseGStreamer uses AtomString in these fields:

    AtomString m_label;
    AtomString m_language;
    AtomString m_stringId;

Additionally, AtomString is received and returned by several methods.

    const AtomString&amp; stringId() const { return m_stringId; };
private:
    static AtomString generateUniquePlaybin2StreamID(TrackType, unsigned index);
    static TrackID trackIdFromStringIdOrIndex(TrackType, const AtomString&amp;, unsigned);

Unfortunately, AtomString is not thread-safe in _at least_ two use cases.

Use case #1: AtomStrings created in one thread cannot be destroyed in another.

I saw this happen in imported/w3c/web-platform-tests/media-source/mediasource-sequencemode-append-buffer.html within a Debug build. It crashed inside the destructor of one of the AtomStrings of TrackPrivateBaseGStreamer, in this assert:

void AtomStringImpl::remove(AtomStringImpl* string)
{
// ...
    ASSERT_WITH_MESSAGE(iterator != atomStringTable.end(), &quot;The string being removed is an atom in the string table of an other thread!&quot;);

Use case #2: The internal ref counting of AtomStrings is also not thread-safe, as found by Eugene: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/1372/commits/33bfbb48666b7de47041e021654894d840b51ff4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2073739</commentid>
    <comment_count>1</comment_count>
    <who name="Alicia Boya García">aboya</who>
    <bug_when>2024-11-08 00:14:53 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/36378</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2073755</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-11-08 01:16:52 -0800</bug_when>
    <thetext>Committed 286324@main (d6348a3fcc70): &lt;https://commits.webkit.org/286324@main&gt;

Reviewed commits have been landed. Closing PR #36378 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>