[llvm] [llvm-nm] Fix msan error in llvm-nm/wasm/weak-symbols.yaml.test (PR #65538)
Daniel Kutenin via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 15:01:32 PDT 2023
https://github.com/danlark1 created https://github.com/llvm/llvm-project/pull/65538:
This happened because we had a section
```
- Index: 3
Kind: DATA
Name: weak_import_data
Flags: [ BINDING_WEAK, UNDEFINED ]
```
Which does not have size. We managed to reproduce it by building llvm under msan with libcxx as a standard library and debug mode with -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK. It called comp(a, a) and full tie detected uninitialized memory
>From 2c87a12bfaed3abff4399af0f6d2859a10d301bb Mon Sep 17 00:00:00 2001
From: Daniel Kutenin <kutdanila at yandex.ru>
Date: Wed, 6 Sep 2023 23:01:20 +0100
Subject: [PATCH] [llvm-nm] Fix msan error in
llvm-nm/wasm/weak-symbols.yaml.test
This happened because we had a section
```
- Index: 3
Kind: DATA
Name: weak_import_data
Flags: [ BINDING_WEAK, UNDEFINED ]
```
Which does not have size. We managed to reproduce it by building llvm under msan with libcxx as a standard library and debug mode with -D_LIBCPP_DEBUG_STRICT_WEAK_ORDERING_CHECK. It called comp(a, a) and full tie detected uninitialized memory
---
llvm/tools/llvm-nm/llvm-nm.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 129eb895bafeeb..79213b3b2c27e3 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -1822,7 +1822,7 @@ static bool getSymbolNamesFromObject(SymbolicFile &Obj,
if (const WasmObjectFile *WasmObj = dyn_cast<WasmObjectFile>(&Obj)) {
const WasmSymbol &WasmSym = WasmObj->getWasmSymbol(Sym);
- if (WasmSym.isTypeData())
+ if (WasmSym.isTypeData() && !WasmSym.isUndefined())
S.Size = WasmSym.Info.DataRef.Size;
}
More information about the llvm-commits
mailing list