unsupported GC: shadow-stack when using MCJIT

I’m getting an error while using a trivial example by just setting a function’s gc to shadow-stack.

Does anybody know why this could be happening?

Most likely a mistake in one of my recent patches. Can you file a bug with a test case? I’ll try to get this fixed quickly.

Philip

Thanks, Philip. I have a sinking feeling it’s not your change, but could you share the commit and so I can try it out locally?

Bug: https://llvm.org/bugs/show_bug.cgi?id=23095

The reason I think it is not your change is because I tried a shared library build of LLVM 3.5.1 and that also failed with this error. Maybe it is because I’m using a package that makes an LLVM DLL for Windows.

The only reason why it show that error is if the static constructor for it didn’t run, right? And I don’t know why it would not run.

By recent, I had meant all my changes in this area over the last six months or so. Given that, it’s entirely possible something got into 3.5.1. I honestly haven’t been tracking the releases closely. I need to take a closer look at your bug report before I can really comment. I’m about to do that, but it’s worth commenting that the shadow stack GC appears to be working normally on a recent linux build. I ran it on a recent build snapshot from the 26th of March I happened to have lying around. Here’s the test code I used: declare void @foo() declare void @llvm.gcroot(i8**, i8*) define void @test(i8* %ptr) gc “shadow-stack” { %slot = alloca i8* call void @llvm.gcroot(i8** %slot, i8* null) store i8* %ptr, i8** %slot call void @foo() %ptr2 = load i8*, i8** %slot store i8 0, i8* %ptr2 ret void }

Ok, I took a look. Its hard for me to tell much from your report. I don’t have Visual Studios (or Windows for that matter) and can’t easily reproduce. It would really help to know if this is a problem with the C bindings or the generated IR. If you manually create the expected IR and run it through opt/llc, does that work? Can you include the full output of this example? Both the IR and the error would be useful to see. One observation, it looks like you’re using the erlang GC not shadow stack? e.g. LLVM.SetGC(sum, “erlang”); Philip

The erlang was a typo, I was trying things out.

I’ve updated the bug with a C program, which exhibits the problem.

To answer your question, given the IR you generated llc/opt does not complain.

This is also happening when using the C++ APIs. It looks like an MCJIT and SetGC interaction.

I’m lost on how to proceed further.

There is a review out, that exposes llvm::linkShadowStackGC to the C bindings.

http://reviews.llvm.org/D8788

Just to circle back here, I did a bit more digging. I'm not entirely sure how this is supposed to work - our linking scheme is a bit of a mess - but here would be the two things I'd try.

Explicitly include:
#include "llvm/CodeGen/LinkAllCodegenComponents.h"

Call the functions:
initializeCore(*Registry);
initializeCodeGen(*Registry);

What I think is happening is that you're getting into the GCStrategy code without having run the initializers for the CodeGen library. Not entirely sure how that's possible, but it appears to be the best explanation for the symptoms.

Philip