https://llvm.org/bugs/show_bug.cgi?id=24207

            Bug ID: 24207
           Summary: Segmentation fault in seemingly valid code
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

A test program for the library GLM (https://github.com/g-truc/glm) is crashing
due to a segmentation fault when compiled with clang++ but not with g++. The
test is "gtx_fast_trigonometry" and can be seen here:
https://github.com/g-truc/glm/blob/master/test/gtx/gtx_fast_trigonometry.cpp

The test is compiled and linked with flags "-std=c++11 -g".

Valgrind gives this trace:

=25726== Invalid read of size 4
==25726==    at 0x407CAB: glm::tvec1<float, (glm::precision)0>
glm::operator*<float, (glm::precision)0>(glm::tvec1<float, (glm::precision)0>
const&, glm::tvec1<float, (glm::precision)0> const&) (type_vec1.inl:434)
==25726==    by 0x407BBA: glm::tvec1<float, (glm::precision)0>
taylorCos::taylorSeriesNewCos6<float, (glm::precision)0,
glm::tvec1>(glm::tvec1<float, (glm::precision)0> const&)
(gtx_fast_trigonometry.cpp:226)
==25726==    by 0x4079F0: glm::tvec1<float, (glm::precision)0>
taylorCos::fastCosNew<float, (glm::precision)0, glm::tvec1>(glm::tvec1<float,
(glm::precision)0> const&) (in
/home/collin/Development/Libraries/builds/glm/test/gtx/test-gtx_fast_trigonometry)
==25726==    by 0x40653E: taylorCos::test() (gtx_fast_trigonometry.cpp:450)
==25726==    by 0x4065CA: main (gtx_fast_trigonometry.cpp:464)
==25726==  Address 0xf7f0002d0 is not stack'd, malloc'd or (recently) free'd

GDB traps at the same point, and a backtrace gives this:

#0  0x0000000000407cab in glm::operator*<float, (glm::precision)0> (v1=...,
v2=...)
    at
/home/collin/Development/Libraries/sources/glm/glm/gtc/../detail/type_vec1.inl:434
#1  0x0000000000407bbb in taylorCos::taylorSeriesNewCos6<float,
(glm::precision)0, glm::tvec1> (x=...)
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:226
#2  0x00000000004079f1 in taylorCos::fastCosNew<float, (glm::precision)0,
glm::tvec1> (x=...)
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:251
#3  0x000000000040653f in taylorCos::test ()
    at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:450
#4  0x00000000004065cb in main () at
/home/collin/Development/Libraries/sources/glm/test/gtx/gtx_fast_trigonometry.cpp:464

At frame #2, `info args` in GDB prints "x = @0x7fff7fffe300: <error reading
variable>", and similar for #1 and #0.

When compiled with g++, the program is Valgrind-clean. I don't see any
undefined behavior in the relevant functions, but I could be wrong. I'm
concerned that there might be a code generation bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to