<?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>301497</bug_id>
          
          <creation_ts>2025-10-26 22:08:57 -0700</creation_ts>
          <short_desc>[JSC] null pointer dereference in SamplingProfiler::processUnverifiedStackTraces()</short_desc>
          <delta_ts>2025-10-27 23:45:49 -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>JavaScriptCore</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="Jarred Sumner">jarred</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>keith_miller</cc>
    
    <cc>syg</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2154371</commentid>
    <comment_count>0</comment_count>
    <who name="Jarred Sumner">jarred</who>
    <bug_when>2025-10-26 22:08:57 -0700</bug_when>
    <thetext>If `calleeBits.asCell()` returns a null pointer, we get a null pointer dereference:

https://github.com/WebKit/WebKit/blob/e4254ec2a5ac077d06a3d9574e36912c95a6dcdb/Source/JavaScriptCore/runtime/SamplingProfiler.cpp#L563-L564

`JSValue::isCell` returns `true` when the `JSValue` is `0`. So this check in HeapUtil is insufficient:

https://github.com/WebKit/WebKit/blob/e4254ec2a5ac077d06a3d9574e36912c95a6dcdb/Source/JavaScriptCore/heap/HeapUtil.h#L86-L90

With UBSAN, this error shows up as:
&gt; runtime error: member call on null pointer of type &apos;const JSC::HeapCell *&apos;

A fix is to check it&apos;s not empty:

diff --git i/Source/JavaScriptCore/runtime/SamplingProfiler.cpp w/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
index 2cafdc0dd6d5..dbc629bbb4ff 100644
--- i/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
+++ w/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
@@ -561,7 +561,7 @@ void SamplingProfiler::processUnverifiedStackTraces()
             }
 
             JSValue callee = calleeBits.asCell();
-            if (!HeapUtil::isValueGCObject(m_vm.heap, filter, callee)) {
+            if (callee.isEmpty() || !HeapUtil::isValueGCObject(m_vm.heap, filter, callee)) {
                 if (!alreadyHasExecutable)
                     stackFrame.frameType = FrameType::Unknown;
                 return;


I don&apos;t know why there&apos;s a null pointer in there to begin with though. That seems like the bigger question.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154644</commentid>
    <comment_count>1</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-10-27 22:31:27 -0700</bug_when>
    <thetext>I think this is possible since stack collection happens at arbitrary timing. Let&apos;s suppress UBSan message via check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154645</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-10-27 22:31:47 -0700</bug_when>
    <thetext>As it happens only when it is nullptr, it is deterministic crash issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154646</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-10-27 22:34:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/163537650&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154647</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-10-27 22:35:22 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/53074</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154656</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-10-27 23:45:46 -0700</bug_when>
    <thetext>Committed 302226@main (c249a7798f86): &lt;https://commits.webkit.org/302226@main&gt;

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

    </bug>

</bugzilla>