[LLVMbugs] [Bug 4585] New: miscompilation at -O1 of luxrender/luxconsole

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jul 19 12:29:42 PDT 2009


           Summary: miscompilation at -O1 of luxrender/luxconsole
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=3216)
 --> (http://llvm.org/bugs/attachment.cgi?id=3216)

Running luxconsole built with llvm-g++ -O1 results in:
[Lux Segmentation fault

-O0 is fine. GCC 4.3 and 4.4 compile luxrender just fine.

I've reduced it to compiling just luxconsole.cpp and api.cpp:

the reduced luxconsole.cpp has (after a bunch of includes):
void foobar() {
      boost::posix_time::time_duration td(0, 0, 1, 0);
      std::stringstream ss;
      ss << td;
    int main(int ac, char *av[]) {
      std::stringstream ss;
      luxError(0, 0, ss.str().c_str());

If compile this at -O1, and link with api.cpp compiled at whatever -O level,
the result is an executable that segfaults. Compiling this at -O0 and api.cpp
at -O1, -O2, ... works.

If I remove the foobar function, or make it static then the segfault
This is strange, because foobar() is  never called/referenced (try renaming to
something random, still crashes). Also if I remove the boost:: stuff from
foobar(), the crash goes away.

Putting luxconsole.cpp and api.cpp in one C++ file, and compiling that at -O1
makes the bug go away too.

Printing something else than ss.str().c_str() (like a constant string) makes
the bug go away too.

Attached is 4710.i, which is the reduced luxconsole.cpp, to reproduce just
compile&run like this:
$ llvm-g++ 4710.i api.i -O && ./a.out
[Lux Segmentation fault

The original luxconsole was valgrind clean, this reduced one has some valgrind
warnings, but works fine with g++, it outputs:
[Lux 2009-Jul-19 22:29:142009-07-19 INFO : 0]

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