[llvm-bugs] [Bug 39491] New: Creating a std::shared_ptr from OrcJit with clang fails
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 29 16:13:14 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39491
Bug ID: 39491
Summary: Creating a std::shared_ptr from OrcJit with clang
fails
Product: libraries
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: OrcJIT
Assignee: unassignedbugs at nondot.org
Reporter: jeanmichael.celerier at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 21055
--> https://bugs.llvm.org/attachment.cgi?id=21055&action=edit
code that reproduces the problem on linux
Hello,
I have the following problem, while trying to JIT-compile some C++ code with
clang under linux.
Basically, I have code that looks like this (full repro attached) :
```
struct blah
{
virtual ~blah();
virtual std::shared_ptr<zob> make() const = 0;
};
struct blah_impl : blah
{
virtual ~blah_impl() { }
virtual std::shared_ptr<zob> make() const { return std::make_shared<zob>();
}
};
extern "C"
__attribute__((visibility("default")))
void* factory()
{
return new blah_impl;
}
```
e.g. an interface defined in my "host" program, which returns a shared_ptr. I
want to JIT-construct specific instances of my interface. Most parts work fine,
except shared_ptr : for some reason, the use_count of the created shared_ptr is
incorrect, which leads to fairly fast crashes.
UBSan complains with the following when running the sample code :
```
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/shared_ptr_base.h:741:36:
runtime error: member call on address 0x6060002a1e80 which does not point to an
object of type 'std::_Sp_counted_base<__gnu_cxx::_S_atomic>'
0x6060002a1e80: note: object is of type 'std::_Sp_counted_ptr_inplace<zob,
std::allocator<zob>, (__gnu_cxx::_Lock_policy)1>'
63 00 00 29 90 67 74 47 4a 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'std::_Sp_counted_ptr_inplace<zob, std::allocator<zob>,
(__gnu_cxx::_Lock_policy)1>'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/shared_ptr_base.h:741:36
in
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/shared_ptr_base.h:203:33:
runtime error: member access within address 0x6060002a1e80 which does not point
to an object of type 'const std::_Sp_counted_base<__gnu_cxx::_S_atomic>'
0x6060002a1e80: note: object is of type 'std::_Sp_counted_ptr_inplace<zob,
std::allocator<zob>, (__gnu_cxx::_Lock_policy)1>'
63 00 00 29 90 67 74 47 4a 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'std::_Sp_counted_ptr_inplace<zob, std::allocator<zob>,
(__gnu_cxx::_Lock_policy)1>'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../include/c++/8.2.1/bits/shared_ptr_base.h:203:33
in
```
This looks like an ABI problem but I am compiling everything with libstdc++, in
the same c++ mode. Most objects passed from the JIT to the host seem to work
fine (vectors, strings, etc), as well as language things that may be impacted
by ABI changes (e.g. destructors). What is going wrong then ?
Thanks
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181029/a9284314/attachment.html>
More information about the llvm-bugs
mailing list