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

The JIT allocates global data inside of function bodies, which can be freed #4855

Closed
rnk opened this issue Jun 30, 2009 · 5 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla mcjit

Comments

@rnk
Copy link
Collaborator

rnk commented Jun 30, 2009

Bugzilla Link 4483
Resolution FIXED
Resolved on Oct 21, 2015 16:41
Version trunk
OS All
Attachments Failing test case.

Extended Description

Consider the program:

int counter = 0;
void foo() { return ++counter; }
void bar() { return ++counter; }

If we use the JIT, and make a call to foo, free the code for foo, and then call bar, we'll access freed memory. Of course, you won't notice the problem until something else is allocated in the freed region, but if you poison freed memory it's easier to detect.

This also interferes with reattempting to JIT machine code, which I was working on when I found this bug. I ran into it because I free the machine code before retrying, and if the function allocated any globals before reattempting, the old addresses are saved in the GlobalValue to address map.

I've attached a failing test case, and I'm working on a fix.

@rnk
Copy link
Collaborator Author

rnk commented Jun 30, 2009

assigned to @rnk

@rnk
Copy link
Collaborator Author

rnk commented Jun 30, 2009

I found the revision that introduced this bug:
http://llvm.org/viewvc/llvm-project?view=rev&revision=54442

The log message is very clear about what it is doing, but it gives no indication as to why the change was made.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 3, 2009

On going discussion on llvmdev. We should add a mechanism to change the behavior.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 9, 2009

r75059 provides a workaround for this. I'm leaving the bug open because the behavior is still broken by default.

@rnk
Copy link
Collaborator Author

rnk commented Oct 21, 2015

The old JIT is gone. I'm pretty sure MCJIT doesn't have this problem.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
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 mcjit
Projects
None yet
Development

No branches or pull requests

2 participants