Skip to content

Conversation

@igorkudrin
Copy link
Collaborator

The test reads 400 bytes of memory above the local variable. If the stack is shallow, this can reach non-allocated space, resulting in a test failure.

The test reads 400 bytes of memory above the local variable. If the
stack is shallow, this can reach non-allocated space, resulting in a
test failure.
@llvmbot
Copy link
Member

llvmbot commented Aug 1, 2025

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

Changes

The test reads 400 bytes of memory above the local variable. If the stack is shallow, this can reach non-allocated space, resulting in a test failure.


Full diff: https://github.com/llvm/llvm-project/pull/151635.diff

1 Files Affected:

  • (modified) lldb/test/API/functionalities/memory/cache/main.cpp (+7-1)
diff --git a/lldb/test/API/functionalities/memory/cache/main.cpp b/lldb/test/API/functionalities/memory/cache/main.cpp
index 44d85c5e9d2c3..a539e48c2cdf4 100644
--- a/lldb/test/API/functionalities/memory/cache/main.cpp
+++ b/lldb/test/API/functionalities/memory/cache/main.cpp
@@ -1,5 +1,11 @@
-int main ()
+int test()
 {
     int my_ints[] = {0x42};
     return 0; // Set break point at this line.
 }
+
+int main ()
+{
+    int dummy[100];
+    return test();
+}

@github-actions
Copy link

github-actions bot commented Aug 1, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I saw the same problem with another test case on Windows on Arm. In that case I was able to lower the amount of memory read, but here it needs to be some amount greater than the l2 cache line size which is 512:

  def MemCacheLineSize: Property<"memory-cache-line-size", "UInt64">,
    DefaultUnsignedValue<512>,
    Desc<"The memory cache line size">;

The test reads 201 * 4 bytes = 804. Starts from -100 from the array, so a 100 item buffer after it makes sense. There will be a few registers in each frame to cover the last 1 integer.

@igorkudrin
Copy link
Collaborator Author

Thanks!

There will be a few registers in each frame to cover the last 1 integer.

I counted my_ints itself for this last 1 integer. Yes, there are some registers stored in the past frames, but there is no point in guessing how many.

@igorkudrin igorkudrin merged commit 55c2b27 into llvm:main Aug 1, 2025
9 checks passed
@igorkudrin igorkudrin deleted the lldb-fix-TestMemoryCache branch August 1, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants