[llvm-bugs] [Bug 50685] New: LLDB sometimes can't determine the dynamic type of an object if the program is compiled with fPIC

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 11 12:54:16 PDT 2021


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

            Bug ID: 50685
           Summary: LLDB sometimes can't determine the dynamic type of an
                    object if the program is compiled with fPIC
           Product: lldb
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: officesamurai at gmail.com
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

If I compile the following code with fPIC or fPIE:
===
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>

void foo(boost::asio::io_context& context)
{
    boost::asio::io_context::strand s{context};
}

struct Base
{
    virtual ~Base() {}
};

struct Derived: Base
{
    Derived(int zzz) : zzz(zzz) {}

    int zzz = 0;
};

int main()
{
    Derived d{123};
    Base* b = &d;

    return 0;
}
===
and run it in lldb, "print b" will print:
(Base *) $0 = 0x00007fffffffdc58

But if I compile it without fPIC/fPIE, or modify the code slightly, e.g. by
commenting out the unused function "foo", I get the expected output:
(Derived *) $0 = 0x00007fffffffdc58

The behaviour doesn't depend on the compiler; I tried clang 11.0 and gcc-10.2
and the result was the same.

Since the code depends on boost, I'm attaching the preprocessed version too.

I compile it as follows:
$ clang++ -g -fPIC test_preproc_clang.cpp -o test -lpthread

Clang version:
Ubuntu clang version 11.0.0-2

LLDB version:
lldb version 12.0.0 (git at github.com:llvm/llvm-project.git revision
d28af7c654d8db0b68c175db5ce212d74fb5e9bc)
  clang revision d28af7c654d8db0b68c175db5ce212d74fb5e9bc
  llvm revision d28af7c654d8db0b68c175db5ce212d74fb5e9bc

boost version: 1.73.0

-- 
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/20210611/87a93944/attachment.html>


More information about the llvm-bugs mailing list