[LLVMbugs] [Bug 1448] NEW: Pointer to invalid memory kept

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat May 26 15:24:30 PDT 2007


http://llvm.org/bugs/show_bug.cgi?id=1448

           Summary: Pointer to invalid memory kept
           Product: tools
           Version: 2.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-ld
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jlh at gmx.ch


In tools/llvm-ld/llvm-ld.cpp, around line 353, a 'const char *' to a temporary 
std::string is being stored, with the string going out of scope right after, 
making that pointer invalid.  Snippet:

    std::string lib_name = "-l" + LinkItems[index].first;
    args.push_back(lib_name.c_str());
    <end of scope>

I originally reported this problem on the llvm-commit list, because I was told 
to do so, but maybe I should have opened a bug report anyway.  See [1] and its 
follow-ups for a simple fix.

Funnily, in my particular case, things still worked fine as long as I only had 
one -l option.  But with several such option, all pointers in 'args' pointed to 
the exact same memory location, still containing the last library name 
processed and gcc got called like "gcc -llib -llib -llib -llib".

[1] http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070430/
048734.html



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the llvm-bugs mailing list