Skip to content
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

Wrong arguments for main() trigger assert in lli #1864

Closed
llvmbot opened this issue Jun 3, 2007 · 6 comments
Closed

Wrong arguments for main() trigger assert in lli #1864

llvmbot opened this issue Jun 3, 2007 · 6 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 3, 2007

Bugzilla Link 1492
Resolution FIXED
Resolved on Feb 22, 2010 12:46
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

This program contains a bug: (argv and argc are swapped)

int main(char** argv, int argc) {
return 0;
}

I compile it to bytecode like this:

$ llvm-g++ --emit-llvm -o wrongmain.bc -c wrongmain.cc

And then run it in the LLVM interpreter like this:

$ lli wrongmain.bc

Which triggers the following assertion:

lli: Instructions.cpp:210: void llvm::CallInst::init(llvm::Value*,
llvm::Value* const*, unsigned int): Assertion `(i >= FTy->getNumParams() ||
FTy->getParamType(i) == Params[i]->getType()) && "Calling a function with a
bad signature!"' failed.
lli((anonymous namespace)::PrintStackTrace()+0x19)[0x847fcb9]
/lib/libc.so.6(abort+0x101)[0xb7ce7801]
/lib/libc.so.6(__assert_fail+0xfb)[0xb7cdf7bb]
lli(llvm::CallInst::init(llvm::Value*, llvm::Value* const*, unsigned
int)+0x181)[0x841adb1]
Aborted

I'm using LLVM 2.0 and its g++ front-end, compiled from source with GCC 4.1.3.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 3, 2007

assigned to @asl

@asl
Copy link
Collaborator

asl commented Jun 3, 2007

This is not a bug. lli cannot know, whether arguments are swapped, dropped, etc.
It supports all 3 types of main():

  • int main(void)
  • int main(argc, argv)
  • int main(argc, argv, envp)

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 3, 2007

Of course the program is wrong, but I think lli should report that with an
error message instead of an assert. If I had compiled the LLVM tools with
asserts off (-DNDEBUG), something undefined could have happened.

@lattner
Copy link
Collaborator

lattner commented Jun 3, 2007

I agree with Maarten. lli should check that the types are right and refuse to run the program if not.

@asl
Copy link
Collaborator

asl commented Jun 3, 2007

Mine

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
troelsbjerre pushed a commit to troelsbjerre/llvm-project that referenced this issue Jan 10, 2024
…llvm#1864)

When a Mach-O corefile has an LC_NOTE "main bin spec" for a
standalone binary / firmware, with only a UUID and no load
address, try to locate the binary and dSYM by UUID and if
found, load it at offset 0 for the user.

Add a test case that tests a firmware/standalone corefile
with both the "kern ver str" and "main bin spec" LC_NOTEs.

<rdar://problem/68193804>

Differential Revision: https://reviews.llvm.org/D88282

(cherry picked from commit 1bec6eb)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants