[LLVMbugs] [Bug 2608] New: The function to stup map in JITResolverState does not get updated when a function is released

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Jul 29 11:41:38 PDT 2008


           Summary: The function to stup map in JITResolverState does not
                    get updated when a function is released
           Product: new-bugs
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ddneff at hotmail.com
                CC: llvmbugs at cs.uiuc.edu, ddneff at hotmail.com

I am currently running into a crash while using the JIT engine where I try to
call Function B, but Function A ends up getting called instead.  Both Function
A and Function B are extern "C" functions in this case.  The reason for the
crash is that the StubToFunctionMap and the FunctionToStubMap inside of
JITResolverState never get updated when a llvm::Function is deleted, even if
you properly call freeMachineCodeForFunction.  A stub is created for Function A
during the JIT process, but when Function A is later deleted the stub mapping
never goes away.  Eventually another llvm::Function will be created that is
given the same exact address as Function A had (stupid memory manager), and
when you try to call this function it ends up calling the stub for the
previously deleted function because of the stale map entry.   I believe that
someplace in either freeMachineCodeForFunction, llvm::Function::~Function, or
some other relevant location these stub mappings need to be cleared out to
prevent stubs from being used after a function is released.  I have tried
adding such code to JITEmitter::deallocateMemForFunction and it fixes my
problem, but the entire stub process is sufficiently complicated enough that I
am not convinced that my solution will work in all cases (it looks like the
stub is also placed into the GOT, and I'm not sure how to correctly deal with
that when the function goes away).

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list