<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 --- - UBSan SEGFAULTs rendering memory at 0x00000001"
   href="http://llvm.org/bugs/show_bug.cgi?id=18058">18058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>UBSan SEGFAULTs rendering memory at 0x00000001
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>compiler-rt
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>tim.besard@elis.ugent.be
          </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>I'm trying to run some code through UBSan, but it crashes when trying to print
memory at address 0x00000001. The code in question comes from
boost::serialization 1.54:

boost/serialization/void_cast.hpp:187:13
    // note:I wanted to display from 0 here, but at least one compiler
    // treated 0 by not shifting it at all.
    reinterpret_cast<std::ptrdiff_t>(
        static_cast<Derived *>(
            reinterpret_cast<Base *>(1)
        )
    ) - 1


UBSan crashes because it detects a misaligned downcasts, after which it tries
to read the memory at 0xx00000001:

    /boost/serialization/void_cast.hpp:187:13: runtime error: downcast of
        misaligned address 0x00000001 for type 'BundleRFRead',
        which requires 4 byte alignment
    0x00000001: note: pointer points here

    Program received signal SIGSEGV, Segmentation fault.
    0x089c36dd in getMemoryLocation () at
      llvm/projects/compiler-rt/lib/ubsan/ubsan_diag.cc:191
    191        Printf("%s%02x", (P % 8 == 0) ? "  " : " ", C);


This is on ToT, with the backtrace as follows:

    #0  0x089c36dd in getMemoryLocation ()
      at llvm/projects/compiler-rt/lib/ubsan/ubsan_diag.cc:191
    #1  ~Diag ()
      at llvm/projects/compiler-rt/lib/ubsan/ubsan_diag.cc:271
    #2  0x089c412f in handleTypeMismatchImpl ()
      at llvm/projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:52
    #3  0x089c3b8f in __ubsan_handle_type_mismatch ()
      at llvm/projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:56</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>