Skip to content

[lldb] Fix plugin manager test failure on windows #134173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged

Conversation

dmpots
Copy link
Contributor

@dmpots dmpots commented Apr 2, 2025

This is an attempt to fix a test failure from #133794 when running on windows builds. I suspect we are running into a case where the ICF optimization kicks in and combines the CreateSystemRuntimePlugin* functions into a single address. This means that we cannot uniquely unregister the plugin based on its create function address.

The fix is have each create function return a different (bogus) value.

This is an attempt to fix a test failure from llvm#133794 when running on
windows builds. I suspect we are running into a case where the
[ICF](https://learn.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170)
optimization kicks in and combines the CreateSystemRuntimePlugin*
functions into a single address. This means that we cannot uniquely
unregister the plugin based on its create function address.

The fix is have each create function return a different (bogus)
value.
@dmpots dmpots requested a review from Jlalond April 2, 2025 23:11
@dmpots dmpots requested a review from JDevlieghere as a code owner April 2, 2025 23:11
@llvmbot llvmbot added the lldb label Apr 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-lldb

Author: David Peixotto (dmpots)

Changes

This is an attempt to fix a test failure from #133794 when running on windows builds. I suspect we are running into a case where the ICF optimization kicks in and combines the CreateSystemRuntimePlugin* functions into a single address. This means that we cannot uniquely unregister the plugin based on its create function address.

The fix is have each create function return a different (bogus) value.


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

1 Files Affected:

  • (modified) lldb/unittests/Core/PluginManagerTest.cpp (+17-3)
diff --git a/lldb/unittests/Core/PluginManagerTest.cpp b/lldb/unittests/Core/PluginManagerTest.cpp
index ca1003ca9a85a..9b0ce2286d273 100644
--- a/lldb/unittests/Core/PluginManagerTest.cpp
+++ b/lldb/unittests/Core/PluginManagerTest.cpp
@@ -7,11 +7,21 @@ using namespace lldb;
 using namespace lldb_private;
 
 // Mock system runtime plugin create functions.
-SystemRuntime *CreateSystemRuntimePluginA(Process *process) { return nullptr; }
+// Make them all return different values to avoid the ICF optimization
+// from combining them into the same function. The values returned
+// are not valid SystemRuntime pointers, but they are unique and
+// sufficient for testing.
+SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
+  return (SystemRuntime *)0x1;
+}
 
-SystemRuntime *CreateSystemRuntimePluginB(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
+  return (SystemRuntime *)0x2;
+}
 
-SystemRuntime *CreateSystemRuntimePluginC(Process *process) { return nullptr; }
+SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
+  return (SystemRuntime *)0x3;
+}
 
 // Test class for testing the PluginManager.
 // The PluginManager modifies global state when registering new plugins. This
@@ -24,6 +34,10 @@ class PluginManagerTest : public testing::Test {
 
   // Add mock system runtime plugins for testing.
   void RegisterMockSystemRuntimePlugins() {
+    // Make sure the create functions all have different addresses.
+    ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
+    ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);
+
     ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
                                               CreateSystemRuntimePluginA));
     ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",

@dmpots
Copy link
Contributor Author

dmpots commented Apr 2, 2025

This is my guess on what is causing the test failures. Can revert this and the original PR if it doesn't work.

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

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

Let's try it!

@dmpots dmpots merged commit b55bab2 into llvm:main Apr 3, 2025
10 of 11 checks passed
@dmpots dmpots deleted the try-icf-fix branch April 3, 2025 00:22
dmpots added a commit to dmpots/llvm-project that referenced this pull request Apr 3, 2025
dmpots added a commit to dmpots/llvm-project that referenced this pull request Apr 3, 2025
Revert the below two commits while we investigate the test failures.

Revert "[lldb] Fix plugin manager test failure on windows (llvm#134173)"

This reverts commit b55bab2.

Revert "Add enable/disable api for SystemRuntime plugins (llvm#133794)"

This reverts commit 2026873.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 3, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/15362

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py (395 of 2115)
PASS: lldb-api :: functionalities/completion/TestCompletion.py (396 of 2115)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py (397 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py (398 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py (399 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py (400 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py (401 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py (402 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (403 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-synthtype/TestDataFormatterSynthType.py (404 of 2115)
FAIL: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py (405 of 2115)
******************** TEST 'lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool -p TestDataFormatterStdVBool.py
--
Exit Code: -11

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision b55bab229228218341e2f24fc8529c7aaab51e2f)
  clang revision b55bab229228218341e2f24fc8529c7aaab51e2f
  llvm revision b55bab229228218341e2f24fc8529c7aaab51e2f
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dsym (TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dwarf (TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dwo (TestDataFormatterStdVBool.StdVBoolDataFormatterTestCase)
----------------------------------------------------------------------
Ran 3 tests in 0.988s

OK (skipped=1)

--

********************
PASS: lldb-api :: functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py (406 of 2115)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/embedded-summary/TestEmbeddedTypeSummary.py (407 of 2115)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py (408 of 2115)
PASS: lldb-api :: functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py (409 of 2115)
PASS: lldb-api :: functionalities/data-formatter/format-propagation/TestFormatPropagation.py (410 of 2115)
PASS: lldb-api :: functionalities/data-formatter/frameformat_smallstruct/TestFrameFormatSmallStruct.py (411 of 2115)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/nsarraysynth/TestNSArraySynthetic.py (412 of 2115)
PASS: lldb-api :: functionalities/data-formatter/hexcaps/TestDataFormatterHexCaps.py (413 of 2115)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/nsdictionarysynth/TestNSDictionarySynthetic.py (414 of 2115)
PASS: lldb-api :: functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py (415 of 2115)

@dmpots
Copy link
Contributor Author

dmpots commented Apr 3, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/15362

Here is the relevant piece of the build log for the reference

Hmm, not sure if this is related. This PR was a test only change so I wouldn't expect these kinds of failures.

#134183 has a revert if we need it

@dmpots
Copy link
Contributor Author

dmpots commented Apr 3, 2025

The windows bots are now passing on this test so I think it was ICF that was the problem: https://lab.llvm.org/buildbot/#/changes/32645

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.

4 participants