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

lli -force-interpreter=true crash at APInt::operator== #1665

Closed
llvmbot opened this issue Mar 30, 2007 · 4 comments
Closed

lli -force-interpreter=true crash at APInt::operator== #1665

llvmbot opened this issue Mar 30, 2007 · 4 comments
Labels
bugzilla Issues migrated from bugzilla code-cleanup

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 30, 2007

Bugzilla Link 1293
Resolution FIXED
Resolved on Feb 22, 2010 12:52
Version trunk
OS Linux
Attachments bytecode crashing the interpreter
Reporter LLVM Bugzilla Contributor

Extended Description

$ lli -force-interpreter=true ./apint.bc
lli: lib/Support/APInt.cpp:491: bool llvm::APInt::operator==(const
llvm::APInt&) const: Assertion `BitWidth == RHS.BitWidth && "Comparison
requires equal bit widths"' failed.

I couldn't get bugpoint to reduce the testcase, so I'm attaching
the compressed bytecode in all its massiveness.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2007

The issue here is this code:

%tmp15.i.i.i = call i32 @​malloc( i32 10256 ) ; [#uses=3]
icmp eq i32 %tmp15.i.i.i, 0 ; :0 [#uses=1]

LLI doesn't know how to coerce the result of malloc to a 32-bit integer from a
pointer. Previously (before APIntification) this would (accidentally) be okay
because the i32 and the pointer value shared the same memory. However, after
APIntification, they don't any more so these kinds of implicit conversions don't
happen any more.

One solution is to just fix the code (define it as returning a void* and then
compare void* instead of i32.

Its not clear how to fix LLI except to make it check for "weird" prototypes of
well known functions. I think that's not worth it.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2007

Perhaps lli should issue a warning that the function its calling is not
returning the correct type.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2007

I have modified LLI to generate this kind of assert:

lli: ExternalFunctions.cpp:157: llvm::GenericValue
lle_X_malloc(llvm::FunctionType*, const std::vector<llvm::GenericValue,
std::allocatorllvm::GenericValue >&): Assertion
`isa(FT->getReturnType()) && "malloc must return pointer"' failed.

It will now do this for all functions that should return pointer values (things
like strcat, strdup, fopen, freopen, etc.).

I think this is about as far as we can go with this.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 30, 2007

@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
…mean-forever-sometimes

Cherry-pick a couple of test fixes
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 code-cleanup
Projects
None yet
Development

No branches or pull requests

1 participant