Get segfault with ModulePass

Hi,

don't know if this is the right list. Please post a better place,
otherwise.

I'm currently writing a LLVM ModulePass and ran into strange segfaults or
endless loops within LLVM. My main question is, if this is a programming error
or API misuse from me or a LLVM bug?

Here is some minimal code, that triggers the bug:

Hi,

Have you tried building LLVM with assertions enabled? Assertions are
often a good way to catch API misuses, but they aren't on by default
for release builds.

FWIW, StringRefs aren't guaranteed to be nul-terminated. They support
a similar comparison API as std::strings, though, so things like
`user->getOpcodeName() == "<Invalid operator>"` should just work™.

George

Hi,

thanks for the answer.

Have you tried dumping the function declaration which crashes ("F->dump()")? I suspect you're running into a function that doesn't have as many arguments as you expect.

-Eli

That was it, thank you. The function has varargs and the i points to the
variable argument.

A simple check prevents the error.

Gerion