[lldb-dev] SystemInitializerCommon::Initialize called twice with shared llvm build

Tamas Berghammer tberghammer at google.com
Wed Jul 15 02:42:26 PDT 2015


Hi Ismall,

lldb-server don't use python at all so a possible fix would be to move the
python initialization from SystemInitializerCommon
to SystemInitializerFull. This change will most likely fix your issue and
it is a reasonable change to make (also independently of this issue) but I
am not sure if it addresses the root cause of the issue you are seeing. So
please feel free to make the change but don't be surprised if the issue
appears in a different scenario also.

Tamas

On Wed, Jul 15, 2015 at 10:33 AM İsmail Dönmez <ismail at donmez.ws> wrote:

> Hi,
>
> Problem seems to be lldb-server itself, looks like python code tries
> to re-initialize, see :
>
> λ gdb --args lldb-server g
> (gdb) b lldb_private::SystemInitializerCommon::Initialize()
> Function "lldb_private::SystemInitializerCommon::Initialize()" not defined.
> Make breakpoint pending on future shared library load? (y or [n]) y
> Breakpoint 1 (lldb_private::SystemInitializerCommon::Initialize()) pending.
> (gdb) r
> Starting program: /opt/clang/bin/lldb-server g
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
>
> Breakpoint 1, lldb_private::SystemInitializerCommon::Initialize
> (this=0x1f88670) at
> ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> 96          Log::Initialize();
> (gdb) bt
> #0  lldb_private::SystemInitializerCommon::Initialize (this=0x1f88670)
> at ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> #1  0x00007fc7709e56aa in
> lldb_private::SystemLifetimeManager::Initialize (this=<optimized out>,
> initializer=..., plugin_callback=0x0) at
> ../tools/lldb/source/Initialization/SystemLifetimeManager.cpp:43
> #2  0x000000000041707e in initialize () at
> ../tools/lldb/tools/lldb-server/lldb-server.cpp:38
> #3  0x0000000000416f5e in main (argc=2, argv=0x7ffc22f92208) at
> ../tools/lldb/tools/lldb-server/lldb-server.cpp:62
> (gdb) c
> Continuing.
> [New process 26104]
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> Thread 0x7fc77128c740 (LWP 26104) is executing new program: /bin/bash
> Thread 0x7fc77128c740 (LWP 26104) is executing new program: /bin/bash
> [New process 26107]
> process 26107 is executing new program: /usr/bin/getopt
> [Inferior 3 (process 26107) exited with code 04]
> (gdb) [New process 26108]
> process 26108 is executing new program: /usr/bin/getopt
> [Inferior 4 (process 26108) exited normally]
> [New process 26109]
> process 26109 is executing new program: /usr/bin/basename
> [Inferior 5 (process 26109) exited normally]
> [New process 26110]
> process 26110 is executing new program: /usr/bin/basename
> [Inferior 6 (process 26110) exited normally]
> [New process 26111]
> process 26111 is executing new program: /usr/bin/basename
> [Inferior 7 (process 26111) exited normally]
> [New process 26112]
> process 26112 is executing new program: /usr/bin/basename
> [Inferior 8 (process 26112) exited normally]
> [New process 26113]
> process 26113 is executing new program: /usr/bin/basename
> [Inferior 9 (process 26113) exited normally]
> [New process 26114]
> process 26114 is executing new program: /usr/bin/basename
> [Inferior 10 (process 26114) exited normally]
> [New process 26115]
> process 26115 is executing new program: /usr/bin/basename
> [Inferior 11 (process 26115) exited normally]
> [New process 26116]
> process 26116 is executing new program: /usr/bin/basename
> [Inferior 12 (process 26116) exited normally]
> [New process 26117]
> [New process 26118]
> [New process 26119]
> [Inferior 14 (process 26118) exited normally]
> process 26119 is executing new program: /usr/bin/sed
> [Inferior 15 (process 26119) exited normally]
> [Inferior 13 (process 26117) exited normally]
> [Inferior 2 (process 26104) exited normally]
> [New process 26120]
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> Thread 0x7fc77128c740 (LWP 26120) is executing new program: /bin/bash
> [New process 26121]
> process 26121 is executing new program: /sbin/ldconfig
> [Inferior 17 (process 26121) exited normally]
> [Inferior 16 (process 26120) exited normally]
>
> Breakpoint 1, lldb_private::SystemInitializerCommon::Initialize
> (this=0x1fb7ed0) at
> ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> 96          Log::Initialize();
> bt
> #0  lldb_private::SystemInitializerCommon::Initialize (this=0x1fb7ed0)
> at ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> #1  0x00007fc77080a4fd in
> lldb_private::SystemInitializerFull::Initialize (this=0x1fb7ed0) at
> ../tools/lldb/source/API/SystemInitializerFull.cpp:226
> #2  0x00007fc7709e56aa in
> lldb_private::SystemLifetimeManager::Initialize (this=<optimized out>,
> initializer=..., plugin_callback=0x7fc7707d1ac0
> <LoadPlugin(std::__1::shared_ptr<lldb_private::Debugger> const&,
> lldb_private::FileSpec const&, lldb_private::Error&)>) at
> ../tools/lldb/source/Initialization/SystemLifetimeManager.cpp:43
> #3  0x00007fc7707d1a97 in lldb::SBDebugger::Initialize () at
> ../tools/lldb/source/API/SBDebugger.cpp:123
> #4  0x00007fc77083f908 in _wrap_SBDebugger_Initialize (args=<optimized
> out>) at tools/lldb/scripts/LLDBWrapPython.cpp:23598
> #5  0x00007fc76a8bffe7 in call_function (oparg=<optimized out>,
> pp_stack=0x7ffc22f917e0) at Python/ceval.c:4035
> #6  PyEval_EvalFrameEx () at Python/ceval.c:2681
> #7  0x00007fc76a8c2642 in fast_function (nk=<optimized out>,
> na=<optimized out>, n=0, pp_stack=0x7ffc22f91920, func=0x7fc763ae99b0)
> at Python/ceval.c:4121
> #8  call_function (oparg=<optimized out>, pp_stack=0x7ffc22f91920) at
> Python/ceval.c:4056
> #9  PyEval_EvalFrameEx () at Python/ceval.c:2681
> #10 0x00007fc76a8be862 in PyEval_EvalCodeEx () at Python/ceval.c:3267
> #11 0x00007fc76a8e22a6 in PyEval_EvalCode (co=co at entry=0x7fc7642517b0,
> globals=globals at entry=0x7fc77117bd70,
> locals=locals at entry=0x7fc77117bd70) at Python/ceval.c:669
> #12 0x00007fc76a8e8be8 in PyImport_ExecCodeModuleEx () at
> Python/import.c:713
> #13 0x00007fc76a8e88f7 in load_source_module () at Python/import.c:1103
> #14 0x00007fc76a8e8d37 in load_package () at Python/import.c:1170
> #15 0x00007fc76a8c4a8d in import_submodule (fullname=0x2016e50 "lldb",
> subname=<optimized out>, mod=0x7fc76ab63f40 <_Py_NoneStruct>) at
> Python/import.c:2704
> #16 load_next (p_buflen=<synthetic pointer>, buf=0x2016e50 "lldb",
> p_name=<synthetic pointer>, altmod=<optimized out>, mod=<optimized
> out>) at Python/import.c:2519
> #17 import_module_level (locals=<optimized out>, level=<optimized
> out>, fromlist=0x7fc76ab63f40 <_Py_NoneStruct>, globals=<optimized
> out>, name=<optimized out>) at Python/import.c:2228
> #18 PyImport_ImportModuleLevel () at Python/import.c:2292
> #19 0x00007fc76a8bdbf8 in builtin___import__ () at Python/bltinmodule.c:49
> #20 0x00007fc76a8aa36b in PyObject_Call () at Objects/abstract.c:2529
> #21 0x00007fc76a8c2890 in PyEval_CallObjectWithKeywords () at
> Python/ceval.c:3904
> #22 0x00007fc76a8c02f7 in PyEval_EvalFrameEx () at Python/ceval.c:2348
> #23 0x00007fc76a8be862 in PyEval_EvalCodeEx () at Python/ceval.c:3267
> #24 0x00007fc76a8e22a6 in PyEval_EvalCode (co=co at entry=0x7fc77116a3b0,
> globals=globals at entry=0x7fc77121ad70,
> locals=locals at entry=0x7fc77121ad70) at Python/ceval.c:669
> #25 0x00007fc76a8ec37d in run_mod (mod=<optimized out>,
> filename=filename at entry=0x7fc76a8f6aeb "<string>",
> globals=globals at entry=0x7fc77121ad70,
> locals=locals at entry=0x7fc77121ad70, flags=flags at entry=0x0,
> arena=arena at entry=0x2051da0) at Python/pythonrun.c:1371
> #26 0x00007fc76a8ec414 in PyRun_StringFlags
> (str=str at entry=0x7fc770cf45b6 "sys.dont_write_bytecode = 1; import
> lldb.embedded_interpreter; from lldb.embedded_interpreter import
> run_python_interpreter; from lldb.embedded_interpreter import
> run_one_line", start=start at entry=257, globals=0x7fc77121ad70,
> locals=0x7fc77121ad70, flags=flags at entry=0x0) at
> Python/pythonrun.c:1334
> #27 0x00007fc76a88f0ed in PyRun_SimpleStringFlags
> (command=0x7fc770cf45b6 "sys.dont_write_bytecode = 1; import
> lldb.embedded_interpreter; from lldb.embedded_interpreter import
> run_python_interpreter; from lldb.embedded_interpreter import
> run_one_line", flags=0x0) at Python/pythonrun.c:975
> #28 0x00007fc770a15ac3 in
> lldb_private::ScriptInterpreterPython::InitializePrivate () at
> ../tools/lldb/source/Interpreter/ScriptInterpreterPython.cpp:3140
> #29 0x00007fc7709e54ea in
> lldb_private::SystemInitializerCommon::Initialize (this=<optimized
> out>) at
> ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:144
> #30 0x00007fc7709e56aa in
> lldb_private::SystemLifetimeManager::Initialize (this=<optimized out>,
> initializer=..., plugin_callback=0x0) at
> ../tools/lldb/source/Initialization/SystemLifetimeManager.cpp:43
> #31 0x000000000041707e in initialize () at
> ../tools/lldb/tools/lldb-server/lldb-server.cpp:38
> #32 0x0000000000416f5e in main (argc=2, argv=0x7ffc22f92208) at
> ../tools/lldb/tools/lldb-server/lldb-server.cpp:62
>
>
> On Tue, Jul 14, 2015 at 6:03 PM, Pavel Labath <labath at google.com> wrote:
> > Hi,
> >
> > I have tried to follow your setup as closely as possible and I still
> > am not able to reproduce this. :/
> >
> > Also, the backtrace you provided are quite strange also. The first one
> > terminates and lldb-server main, while the second one ends in lldb.
> > This is to be expected if they are from different processes since both
> > of them do initialization. Are you sure these backtraces are from the
> > same process? If so, then please find out why are both main()
> > functions being executed.
> >
> > pl
> >
> >
> > On 14 July 2015 at 12:04, İsmail Dönmez <ismail at donmez.ws> wrote:
> >> And setting a break point on
> >> lldb_private::SystemInitializerCommon::Initialize() shows that 2
> >> initializations indeed:
> >>
> >> First one:
> >>
> >> #0  lldb_private::SystemInitializerCommon::Initialize (this=0x1ccec10)
> >> at ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> >> #1  0x00007f76d64385cd in
> >> lldb_private::SystemInitializerFull::Initialize (this=0x1ccec10) at
> >> ../tools/lldb/source/API/SystemInitializerFull.cpp:226
> >> #2  0x00007f76d6612a3a in
> >> lldb_private::SystemLifetimeManager::Initialize (this=<optimized out>,
> >> initializer=..., plugin_callback=0x7f76d63ffbf0
> >> <LoadPlugin(std::__1::shared_ptr<lldb_private::Debugger> const&,
> >> lldb_private::FileSpec const&, lldb_private::Error&)>) at
> >> ../tools/lldb/source/Initialization/SystemLifetimeManager.cpp:43
> >> #3  0x00007f76d63ffbc7 in lldb::SBDebugger::Initialize () at
> >> ../tools/lldb/source/API/SBDebugger.cpp:123
> >> #4  0x00000000004063bb in main (argc=1, argv=0x7ffc50c8c948,
> >> envp=0x7f76d6438f80 <LLDBSwigPythonWatchpointCallbackFunction(char
> >> const*, char const*, lldb::StackFrameSP const&, lldb::WatchpointSP
> >> const&)>) at ../tools/lldb/tools/driver/Driver.cpp:1223
> >>
> >> Second one (this happens after I do "file ls" and "r") :
> >>
> >> #0  lldb_private::SystemInitializerCommon::Initialize (this=0x1096850)
> >> at ../tools/lldb/source/Initialization/SystemInitializerCommon.cpp:96
> >> #1  0x00007f11ba252a3a in
> >> lldb_private::SystemLifetimeManager::Initialize (this=<optimized out>,
> >> initializer=..., plugin_callback=0x0) at
> >> ../tools/lldb/source/Initialization/SystemLifetimeManager.cpp:43
> >> #2  0x00000000004160fe in initialize () at
> >> ../tools/lldb/tools/lldb-server/lldb-server.cpp:38
> >> #3  0x0000000000415fde in main (argc=6, argv=0x7ffc6179b168) at
> >> ../tools/lldb/tools/lldb-server/lldb-server.cpp:62
> >>
> >>
> >>
> >> On Tue, Jul 14, 2015 at 1:44 PM, İsmail Dönmez <ismail at donmez.ws>
> wrote:
> >>> Hi,
> >>>
> >>> On Tue, Jul 14, 2015 at 1:41 PM, Pavel Labath <labath at google.com>
> wrote:
> >>>> Hi,
> >>>>
> >>>> i've just tried a cmake build with BUILD_SHARED_LIBS=1 and it seems to
> >>>> work for me. Could you share the exact command you use to build? Also,
> >>>> are you using the latest version from svn?
> >>>
> >>> Yes this is the latest version from svn, but note that I build lldb
> >>> together with llvm/clang and compiler-rt, exact command line is:
> >>>
> >>> cmake -G "Ninja" \
> >>>     -DCMAKE_BUILD_TYPE=RelWithDebInfo \
> >>>     -DBUILD_SHARED_LIBS=ON \
> >>>     -DLLVM_LIBDIR_SUFFIX=64 \
> >>>     -DLLVM_REQUIRES_RTTI=ON \
> >>>     -DLLVM_ENABLE_TIMESTAMPS=OFF \
> >>>     -DLLVM_ENABLE_ASSERTIONS=ON \
> >>>     -DLLVM_ENABLE_PIC=ON \
> >>>     -DLLVM_BINUTILS_INCDIR=/usr/include \
> >>>     -DLLVM_TARGETS_TO_BUILD=host \
> >>>     -DLLVM_ENABLE_FFI=ON \
> >>>     -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp \
> >>>     -DLLVM_ENABLE_LIBCXX=ON \
> >>>     ..
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150715/4876767a/attachment.html>


More information about the lldb-dev mailing list