Skip to content

Commit

Permalink
[mono] Unconditionally check llvm::Expected<T> for success (#44908)
Browse files Browse the repository at this point in the history
`assert()` will expand to a no-op if NDEBUG is defined, which can
cause an assertion-enabled LLVM to trap if an `llvm::Expected<T>` is
destroyed before having had `operator bool` applied to it.
  • Loading branch information
imhameed authored Nov 19, 2020
1 parent cb8c8ec commit b5dffeb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mono/mono/mini/llvm-jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ struct MonoLLVMJIT {
auto k = add_module (std::unique_ptr<Module>(module));
auto bodysym = compile_layer.findSymbolIn (k, mangle (func), false);
auto bodyaddr = bodysym.getAddress ();
assert (bodyaddr);
if (!bodyaddr)
g_assert_not_reached();
for (int i = 0; i < nvars; ++i) {
auto var = unwrap<GlobalVariable> (callee_vars[i]);
auto sym = compile_layer.findSymbolIn (k, mangle (var->getName ()), true);
Expand Down Expand Up @@ -404,7 +405,8 @@ class MonoLLVMJIT {
auto ModuleHandle = addModule (F, m);
auto BodySym = CompileLayer.findSymbolIn(ModuleHandle, mangle (F), false);
auto BodyAddr = BodySym.getAddress();
assert (BodyAddr);
if (!BodyAddr)
g_assert_not_reached ();

for (int i = 0; i < nvars; ++i) {
GlobalVariable *var = unwrap<GlobalVariable>(callee_vars [i]);
Expand Down

0 comments on commit b5dffeb

Please sign in to comment.