<div dir="ltr">FYI:  The problem was the SWIG bug that becomes critical when combined with Python 3.7+.  Updating SWIG to 4.0.2 resolved all of the test failures.<div><br></div><div>I'm not sure why this wasn't consistently a problem before, though, since I was already using this combination of versions for a while before the tests started failing.</div><div><br></div><div>There's actually a Cmake warning about the version incompatibility.  I'm going to propose that this warning be upgraded to an error.</div><div><br></div><div>Thanks everyone!</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 10, 2020 at 3:06 PM Tatyana Krasnukha <<a href="mailto:Tatyana.Krasnukha@synopsys.com">Tatyana.Krasnukha@synopsys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_8105570937243656037WordSection1">
<p class="MsoNormal">On Windows one should run debug version of Python (python_d.exe) to load debug version of liblldb.dll. I hope this will help you.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>From:</b> lldb-dev <<a href="mailto:lldb-dev-bounces@lists.llvm.org" target="_blank">lldb-dev-bounces@lists.llvm.org</a>> <b>On Behalf Of
</b>Adrian McCarthy via lldb-dev<br>
<b>Sent:</b> Tuesday, November 10, 2020 4:00 AM<br>
<b>To:</b> Ted Woodward <<a href="mailto:tedwood@quicinc.com" target="_blank">tedwood@quicinc.com</a>><br>
<b>Cc:</b> LLDB <<a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [lldb-dev] Need help with failing LLDB tests on Windows<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Thanks for all the info and pointers.  That's helping me zero in on the problem.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This category of the failures appears to all be dotest.py tests, so it makes sense that it's the second import statement (per Pavel's explanation).<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The module is not being found because it's actually named _lldb_d.pyd.  Apparently the `_d` suffix is because I'm building debug.  That seems consistent with Stella's experience.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">However, I've been building debug since before these problems arose.  (In fact, I've been working on fixes for a small number of tests that only fail in debug, because of an assertion that detects the problem.)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Ted's got me thinking that it was working due to a symlink that somehow got blown away and/or isn't being recreated by the build.  If I recall correctly, the symlinks on Windows are created using ln.exe, which may come from GnuWin32 or
 from git/usr/bin.  In my case, it's git/usr/bin.  There seem to have been many git updates in the past couple months, so perhaps one of those updates tweaked ln.exe.  That could have been the trigger for me.  Folks who didn't take the git update or who are
 configured to prefer GnuWin32 tools might not have been affected.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I'll let you know what I eventually find.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Nov 4, 2020 at 12:05 PM Ted Woodward <<a href="mailto:tedwood@quicinc.com" target="_blank">tedwood@quicinc.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">To expand a bit on what Pavel has written, the lldb module should be in <install>\lib\site-packages\lldb . In that directory is a file, _lldb.pyd, that should be a copy of <install>\bin\liblldb.dll .<br>
<br>
Do both files exist? Is _lldb.pyd a copy of liblldb.dll?<br>
See function create_relative_symlink in llvm-project/lldb/CMakeLists.txt for the copy (on non-unix hosts) procedure.<br>
<br>
Did you recently change your version of swig? LLDB requires swig 2, but, as you pointed out last year, there are issues with some versions of swig. We use 4.0.1 on Windows.<br>
<br>
> -----Original Message-----<br>
> From: lldb-dev <<a href="mailto:lldb-dev-bounces@lists.llvm.org" target="_blank">lldb-dev-bounces@lists.llvm.org</a>> On Behalf Of Pavel Labath<br>
> via lldb-dev<br>
> Sent: Wednesday, November 4, 2020 2:49 AM<br>
> To: Adrian McCarthy <<a href="mailto:amccarth@google.com" target="_blank">amccarth@google.com</a>>; LLDB <lldb-<br>
> <a href="mailto:dev@lists.llvm.org" target="_blank">dev@lists.llvm.org</a>><br>
> Subject: [EXT] Re: [lldb-dev] Need help with failing LLDB tests on Windows<br>
><br>
> On 04/11/2020 01:53, Adrian McCarthy via lldb-dev wrote:<br>
> > For the past couple weeks, I've been trying to figure out why<br>
> > approximately 900+ LLDB tests have been failing for me on my local<br>
> > Windows builds.  Bisect turned up nothing--the "good" version that was<br>
> > working for me no longer works.  Since nobody else seems to be seeing<br>
> > these failures, I suspect it's something environmental.<br>
> ><br>
> > There are three categories of errors.  I'm currently focused on<br>
> > failures that look like this:<br>
> ><br>
> >     FAIL: lldb-api :: lang/objc/unicode-string/TestUnicodeString.py (732<br>
> >     of 2180)<br>
> >     ******************** TEST 'lldb-api ::<br>
> >     lang/objc/unicode-string/TestUnicodeString.py' FAILED<br>
> >     ********************<br>
> >     Script:<br>
> >     --<br>
> >     C:/Program Files/Python38/python.exe<br>
> >     D:/src/llvm/llvm-project/lldb\test\API\dotest.py -S nm -u CXXFLAGS<br>
> >     -u CFLAGS --enable-crash-dialog --env<br>
> >     LLVM_LIBS_DIR=D:/src/llvm/build/ninja_dbg/./lib --arch x86_64<br>
> >     --build-dir D:/src/llvm/build/ninja_dbg/lldb-test-build.noindex -s<br>
> >     D:/src/llvm/build/ninja_dbg/lldb-test-traces --lldb-module-cache-dir<br>
> >     D:/src/llvm/build/ninja_dbg/lldb-test-build.noindex/module-cache-<br>
> lldb\lldb-api<br>
> >     --clang-module-cache-dir<br>
> >     D:/src/llvm/build/ninja_dbg/lldb-test-build.noindex/module-cache-<br>
> clang\lldb-api<br>
> >     --executable D:/src/llvm/build/ninja_dbg/./bin/lldb.exe --compiler<br>
> >     D:/src/llvm/build/ninja_dbg/bin/clang.exe --dsymutil<br>
> >     D:/src/llvm/build/ninja_dbg/./bin/dsymutil.exe --filecheck<br>
> >     D:/src/llvm/build/ninja_dbg/./bin/FileCheck.exe --yaml2obj<br>
> >     D:/src/llvm/build/ninja_dbg/./bin/yaml2obj.exe --lldb-libs-dir<br>
> >     D:/src/llvm/build/ninja_dbg/./lib<br>
> >     D:\src\llvm\llvm-project\lldb\test\API\lang\objc\unicode-string -p<br>
> >     TestUnicodeString.py<br>
> >     --<br>
> >     Exit Code: 1<br>
> ><br>
> >     Command Output (stdout):<br>
> >     --<br>
> >     lldb version 12.0.0 (<a href="https://urldefense.com/v3/__https:/github.com/llvm/llvm-project.git__;!!A4F2R9G_pg!Jabk6KDSuWsHly57fuTAqQs8uS9tkYAt92H-UgbVnuz-reHkfeimBjQbWAe1kxnspRrcm9D_$" target="_blank">https://github.com/llvm/llvm-project.git</a><br>
> >     <<a href="https://urldefense.com/v3/__https:/github.com/llvm/llvm-project.git__;!!A4F2R9G_pg!Jabk6KDSuWsHly57fuTAqQs8uS9tkYAt92H-UgbVnuz-reHkfeimBjQbWAe1kxnspRrcm9D_$" target="_blank">https://github.com/llvm/llvm-project.git</a>> revision<br>
> >     0fdcd1ae1c988fa19d0c97e99999e8678b93a0da)<br>
> >        clang revision 0fdcd1ae1c988fa19d0c97e99999e8678b93a0da<br>
> >        llvm revision 0fdcd1ae1c988fa19d0c97e99999e8678b93a0da<br>
> ><br>
> >     --<br>
> >     Command Output (stderr):<br>
> >     --<br>
> >     Traceback (most recent call last):<br>
> >        File<br>
> >     "D:\src\llvm\build\ninja_dbg\Lib\site-packages\lldb\__init__.py",<br>
> >     line 35, in <module><br>
> >          import _lldb<br>
> >     ModuleNotFoundError: No module named '_lldb'<br>
> ><br>
> >     During handling of the above exception, another exception occurred:<br>
> ><br>
> >     Traceback (most recent call last):<br>
> >        File "D:/src/llvm/llvm-project/lldb\test\API\dotest.py", line 7,<br>
> >     in <module><br>
> >          lldbsuite.test.run_suite()<br>
> >        File<br>
> >     "D:\src\llvm\llvm-<br>
> project\lldb\packages\Python\lldbsuite\test\dotest.py",<br>
> >     line 874, in run_suite<br>
> >          import lldb<br>
> >        File<br>
> >     "D:\src\llvm\build\ninja_dbg\Lib\site-packages\lldb\__init__.py",<br>
> >     line 38, in <module><br>
> >          from . import _lldb<br>
> >     ImportError: cannot import name '_lldb' from partially initialized<br>
> >     module 'lldb' (most likely due to a circular import)<br>
> >     (D:\src\llvm\build\ninja_dbg\Lib\site-packages\lldb\__init__.py)<br>
> ><br>
> ><br>
> > It looks like the code in question is generated by Swig (so perhaps it<br>
> > depends on the version of Swig?).  The relevant bit seems to be:<br>
> ><br>
> >     try:<br>
> >          # Try an absolute import first.  If we're being loaded from lldb,<br>
> >          # _lldb should be a built-in module.<br>
> >          import _lldb<br>
> >     except ImportError:<br>
> >          # Relative import should work if we are being loaded by Python.<br>
> >     from . import _lldb<br>
> ><br>
> ><br>
> > I don't have much background in Python modules or how Swig produces<br>
> > the bindings.  It seems suspicious to me that both import attempts are<br>
> > failing (and that we need two).<br>
><br>
> The reason behind the two imports is that lldb+python have two ways of<br>
> loading each other, depending on who is "on top".<br>
><br>
> If you're starting with a c++ program (e.g. lldb driver), then the (lib)lldb library<br>
> will be loaded first. It will register itself as a "builtin" python module so that<br>
> "import _lldb" loads _it_, instead of trying to load another copy of lldb.<br>
><br>
> OTOH, if we are starting from python (like the dotests do), then there is no<br>
> builtin module, and we want to use the second import statement to load lldb<br>
> relative to the __init__.py location.<br>
><br>
> The fact that the selection of the two methods is implemented by catching<br>
> the exceptions from the first attempt is not ideal. It's possible this could be<br>
> implemented differently (we'd need to find some other way to determine<br>
> which scenario are we in). However, I don't think that will fix the problem<br>
> you're running into.<br>
><br>
> Regarding python3.8+windows, we also have this<br>
> <<a href="https://urldefense.com/v3/__https:/bugs.llvm.org/show_bug.cgi?id=46891__;!!A4F2R9G_pg!Jabk6KDSuWsHly57fuTAqQs8uS9tkYAt92H-UgbVnuz-reHkfeimBjQbWAe1kxnspUyzoU1N$" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=46891</a>> bug open, but that
 also<br>
> doesn't sound like the same issue.<br>
><br>
> BTW, this particular piece of code comes from<br>
> lldb/bindings/python/python.swig, so it is fairly easy to change that.<br>
><br>
> >  I'm hoping someone can offer some clues  about what's going on here<br>
> >and how it's supposed to work.  Is the hint  about an import cycle<br>
> >relevant or a red herring?<br>
><br>
> It sounds like a red herring. I get the same error (on linux+python3.8) if I<br>
> delete _lldb.so. So it sounds to me like python is having trouble finding the<br>
> native module (either it's not there or it has wrong debug-ness).<br>
><br>
> It's also good to check whether you are able to use python scripting from<br>
> inside the lldb driver (e.g. lldb -o "script 1+1").<br>
><br>
> pl<br>
> _______________________________________________<br>
> lldb-dev mailing list<br>
> <a href="mailto:lldb-dev@lists.llvm.org" target="_blank">lldb-dev@lists.llvm.org</a><br>
> <a href="https://urldefense.com/v3/__https:/lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev__;!!A4F2R9G_pg!Jabk6KDSuWsHly57fuTAqQs8uS9tkYAt92H-UgbVnuz-reHkfeimBjQbWAe1kxnspd0OYR0R$" target="_blank">
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>

</blockquote></div>