<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 11, 2015 at 7:02 AM, Ben Pope <span dir="ltr"><<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wednesday, May 06, 2015 01:50 AM, Alexey Samsonov wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
On Mon, May 4, 2015 at 5:27 PM, Ben Pope<br>
<<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a>>> wrote:<br>
<br>
    On Tuesday, May 05, 2015 12:08 AM, Alexey Samsonov wrote:<br>
<br>
        Hi Ben,<br>
<br>
        On Sun, May 3, 2015 at 9:52 PM, Ben Pope<br>
        <<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a><br>
        <mailto:<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a>><br></span>
        <mailto:<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a><div><div class="h5"><br>
        <mailto:<a href="mailto:benpope81@gmail.com" target="_blank">benpope81@gmail.com</a>>>> wrote:<br>
<br>
             When I run with UBSAN over the Boost libraries, I get a lot of<br>
             output of the form:<br>
             ==20717==Sanitizer CHECK failed:<br>
<br>
        /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_init.cc:60<br>
             ((UBSAN_MODE_UNKNOWN)) != ((ubsan_mode)) (0, 0)<br>
<br>
             I'm not sure what's going wrong, I was expecting something more<br>
             descriptive!<br>
<br>
<br>
        Right, I should probably add more descriptive error message...<br>
<br>
        Can you provide the details of how you compile<br>
        your source files and link them into libraries and executable?<br>
        It looks<br>
        like your executable is linked with both UBSan<br>
        runtime and ASan runtime. It can happen if the link flags used were<br>
        inconsistent, or you mix libraries/executables<br>
        built with different versions of Clang.<br>
<br>
<br>
    It's not impossible, but I don't think I'm linking both runtimes.<br>
<br>
<br>
    Here's an example:<br>
    <a href="http://www.boost.org/development/tests/develop/developer/output/BenPope%20x86_64%20Ubuntu-boost-bin-v2-libs-algorithm-test-all_of_test-test-clang-linux-3-7~ubsan~c14_libc++-debug.html" target="_blank">http://www.boost.org/development/tests/develop/developer/output/BenPope%20x86_64%20Ubuntu-boost-bin-v2-libs-algorithm-test-all_of_test-test-clang-linux-3-7~ubsan~c14_libc++-debug.html</a><br>
<br>
<br>
<br>
Indeed, looks like the compile/link commands are reasonable, and the<br>
problem is somewhere else. On Linux, we assume that UBSan runtime will<br>
be initialized by calling __ubsan::InitAsStandalone() from<br>
.preinit_array section (i.e. very early), and that subsequent calls to<br>
__ubsan::InitAsStandaloneIfNecessary() will<br>
effectively be a no-op. Apparently, this assumption doesn't hold in your<br>
case.<br>
<br>
Can you send me a stack trace of this CHECK-failure? (i.e. run the<br>
executable under gdb and fetch stack trace from it).<br>
</div></div></blockquote>
<br></blockquote><div><br></div><div>Thanks for the stacktrace!</div><div><br></div><div>Looks like I've fixed the problem in LLVM r237045: due to a bug, UBSan initialization was *not* called from .preinit_array as</div><div>it was supposed to, and if the function called from .init_array early enough contained an error and tried to report it</div><div>(as in your case), the runtime was still in uninitialized state.</div><div><br></div><div>Could you please test your code with trunk Clang?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Apologies for the delay.<br>
<br>
Breakpoint 2, __ubsan::InitAsStandaloneIfNecessary() () at /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_init.cc:60<br>
60          CHECK_NE(UBSAN_MODE_UNKNOWN, ubsan_mode);<br>
(gdb) bt<br>
#0  __ubsan::InitAsStandaloneIfNecessary() () at /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_init.cc:60<br>
#1  0x0000555555598da2 in ScopedReport () at /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_diag.cc:336<br>
#2  0x0000555555599480 in handleTypeMismatchImpl () at /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:54<br>
#3  0x0000555555599362 in __ubsan_handle_type_mismatch () at /home/ben/development/llvm/trunk/llvm/projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:75<br>
#4  0x00007ffff77e25d0 in __self (this=<optimized out>) at /home/ben/development/llvm/trunk/install/release/bin/../include/c++/v1/list:218<br>
#5  __list_node_base (this=<optimized out>) at /home/ben/development/llvm/trunk/install/release/bin/../include/c++/v1/list:213<br>
#6  __list_imp (this=<optimized out>) at /home/ben/development/llvm/trunk/install/release/bin/../include/c++/v1/list:546<br>
#7  list (this=0x7ffff7dd7fb8 <boost::unit_test::runtime_config::(anonymous namespace)::s_test_to_run>) at /home/ben/development/llvm/trunk/install/release/bin/../include/c++/v1/list:819<br>
#8  __cxx_global_var_init83 () at ../boost/test/impl/unit_test_parameters.ipp:224<br>
#9  0x00007ffff7de95ba in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffdee8, env=env@entry=0x7fffffffdef8) at dl-init.c:72<br>
#10 0x00007ffff7de96cb in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:30<br>
#11 _dl_init (main_map=0x7ffff7ffe188, argc=1, argv=0x7fffffffdee8, env=0x7fffffffdef8) at dl-init.c:120<br>
#12 0x00007ffff7dd9d0a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2<br>
#13 0x0000000000000001 in ?? ()<br>
#14 0x00007fffffffe248 in ?? ()<br>
#15 0x0000000000000000 in ?? ()<div class="HOEnZb"><div class="h5"><br>
<br>
Ben<br>
<br>
<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@cs.uiuc.edu" target="_blank">cfe-users@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>