<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Compiling with --coverage leads to a segmentation fault"
   href="http://llvm.org/bugs/show_bug.cgi?id=20530">20530</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiling with --coverage leads to a segmentation fault
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chretien@lirmm.fr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling one of our projects (<a href="https://github.com/roboptim/roboptim-core">https://github.com/roboptim/roboptim-core</a>)
with clang on Linux with the --coverage option, we end up with a segmentation
fault at the end of some of the programs:

gdb output:

Program received signal SIGSEGV, Segmentation fault.
=> 0x7ffff7ee97b0:  Error while running hook_stop:
Cannot access memory at address 0x7ffff7ee97b0
#0  0x00007ffff7ee97b0 in ?? ()
#1  0x00007ffff7767a54 in llvm_writeout_files () from
.../roboptim-core/build/src/libroboptim-core.so.2
#2  0x00007ffff5a11c1f in __cxa_finalize () from /usr/lib/libc.so.6
#3  0x00007ffff758edd3 in __do_global_dtors_aux () from
/home/ben/dev/roboptim-core/build/src/libroboptim-core.so.2
#4  0x00007fffffffe1e0 in ?? ()
#5  0x00007ffff7deb657 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
Backtrace stopped: frame did not save the PC

valgrind output:

 Jump to the invalid address stated on the next line
==21273==    at 0x40A0790: ???
==21273==    by 0x546AA53: llvm_writeout_files (in
.../roboptim-core/build/src/libroboptim-core.so.2.0.0)
==21273==    by 0x6EBCC1E: __cxa_finalize (in /usr/lib/libc-2.19.so)
==21273==    by 0x5291DD2: ??? (in
.../roboptim-core/build/src/libroboptim-core.so.2.0.0)
==21273==    by 0x400F656: _dl_fini (in /usr/lib/ld-2.19.so)
==21273==    by 0x6EBC881: __run_exit_handlers (in /usr/lib/libc-2.19.so)
==21273==    by 0x6EBC8D4: exit (in /usr/lib/libc-2.19.so)
==21273==    by 0x6EA6006: (below main) (in /usr/lib/libc-2.19.so)
==21273==  Address 0x40a0790 is not stack'd, malloc'd or (recently) free'd
==21273== 
==21273== 
==21273== Process terminating with default action of signal 11 (SIGSEGV)
==21273==  Access not within mapped region at address 0x40A0790
==21273==    at 0x40A0790: ???
==21273==    by 0x546AA53: llvm_writeout_files (in
.../roboptim-core/build/src/libroboptim-core.so.2.0.0)
==21273==    by 0x6EBCC1E: __cxa_finalize (in /usr/lib/libc-2.19.so)
==21273==    by 0x5291DD2: ??? (in
.../roboptim-core/build/src/libroboptim-core.so.2.0.0)
==21273==    by 0x400F656: _dl_fini (in /usr/lib/ld-2.19.so)
==21273==    by 0x6EBC881: __run_exit_handlers (in /usr/lib/libc-2.19.so)
==21273==    by 0x6EBC8D4: exit (in /usr/lib/libc-2.19.so)
==21273==    by 0x6EA6006: (below main) (in /usr/lib/libc-2.19.so)


Note that everything works perfectly with gcc on Linux, or even clang on OSX
(at least the version used by the osx virtual machine on Travis), and
everything works fine if we remove the --coverage option.

If you want to test our code:

Requirements:
 * CMake
 * Git
 * Eigen >= 3.2
 * Boost
 * pkg-config
 * log4cxx
 * libtool

Getting and running the code:

$ git clone --recursive <a href="https://github.com/roboptim/roboptim-core.git">https://github.com/roboptim/roboptim-core.git</a>
$ cd roboptim-core && mkdir build && cd build
$ cmake .. -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage
-DCMAKE_MODULE_LINKER_FLAGS=--coverage -DCMAKE_CXX_COMPILER=/usr/bin/clang++
-DCMAKE_C_COMPILER=/usr/bin/clang
$ make
$ make test

You should get (with clang + --coverage on Linux):

The following tests FAILED:
     18 - solver-factory (SEGFAULT)
     21 - example (SEGFAULT)
     22 - plugin (SEGFAULT)
     23 - plugin-laststate (SEGFAULT)
     25 - optimization-logger (SEGFAULT)
     26 - multiplexer (SEGFAULT)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>