@@ -937,6 +937,18 @@ Recycler::SetIsInScript(bool isInScript)
937
937
this ->isInScript = isInScript;
938
938
}
939
939
940
+ bool
941
+ Recycler::HasNativeGCHost () const
942
+ {
943
+ return this ->hasNativeGCHost ;
944
+ }
945
+
946
+ void
947
+ Recycler::SetHasNativeGCHost ()
948
+ {
949
+ this ->hasNativeGCHost = true ;
950
+ }
951
+
940
952
bool
941
953
Recycler::NeedOOMRescan () const
942
954
{
@@ -1680,7 +1692,7 @@ Recycler::ScanStack()
1680
1692
1681
1693
BEGIN_DUMP_OBJECT (this , _u (" Registers" ));
1682
1694
// We will not scan interior pointers on stack if we are not in script or we are in mem-protect mode.
1683
- if (!this ->isInScript || this ->IsMemProtectMode ())
1695
+ if (!this ->HasNativeGCHost () && (! this -> isInScript || this ->IsMemProtectMode () ))
1684
1696
{
1685
1697
if (doSpecialMark)
1686
1698
{
@@ -1699,7 +1711,7 @@ Recycler::ScanStack()
1699
1711
{
1700
1712
// We may have interior pointers on the stack such as pointers in the middle of the character buffers backing a JavascriptString or SubString object.
1701
1713
// To prevent UAFs of these buffers after the GC we will always do MarkInterior for the pointers on stack. This is necessary only when we are doing a
1702
- // GC while running a script as that is when the possiblity of a UAF after GC exists .
1714
+ // GC while running a script or when we have a host who allocates objects on the Chakra heap .
1703
1715
if (doSpecialMark)
1704
1716
{
1705
1717
ScanMemoryInline<true , true /* forceInterior */ >(this ->savedThreadContext .GetRegisters (), sizeof (void *) * SavedRegisterState::NumRegistersToSave
@@ -1715,7 +1727,7 @@ Recycler::ScanStack()
1715
1727
1716
1728
BEGIN_DUMP_OBJECT (this , _u (" Stack" ));
1717
1729
// We will not scan interior pointers on stack if we are not in script or we are in mem-protect mode.
1718
- if (!this ->isInScript || this ->IsMemProtectMode ())
1730
+ if (!this ->HasNativeGCHost () && (! this -> isInScript || this ->IsMemProtectMode () ))
1719
1731
{
1720
1732
if (doSpecialMark)
1721
1733
{
@@ -1732,7 +1744,7 @@ Recycler::ScanStack()
1732
1744
{
1733
1745
// We may have interior pointers on the stack such as pointers in the middle of the character buffers backing a JavascriptString or SubString object.
1734
1746
// To prevent UAFs of these buffers after the GC we will always do MarkInterior for the pointers on stack. This is necessary only when we are doing a
1735
- // GC while running a script as that is when the possiblity of a UAF after GC exists .
1747
+ // GC while running a script or when we have a host who allocates objects on the Chakra heap .
1736
1748
if (doSpecialMark)
1737
1749
{
1738
1750
ScanMemoryInline<true , true /* forceInterior */ >((void **)stackTop, stackScanned
0 commit comments