llvm-project/lldb
Vedant Kumar f807d0b4ac [lldb/test] Fix for flakiness in TestNSDictionarySynthetic
Summary:
TestNSDictionarySynthetic sets up an NSURL which does not initialize its
_baseURL member. When the test runs and we print out the NSURL, we print
out some garbage memory pointed-to by the _baseURL member, like:

```
_baseURL = 0x0800010020004029 @"d��qX"
```

and this can cause a python unicode decoding error like:

```
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position
10309: invalid start byte
```

There's a discrepancy here because lldb's StringPrinter facility tries
to only print out "printable" sequences (see: isprint32()), whereas python
rejects the StringPrinter output as invalid utf8. For the specific error
seen above, lldb's `isprint32(0xa0) = true`, even though 0xa0 is not
really "printable" in the usual sense.

The problem is that lldb and python disagree on what exactly is
"printable". Both have dismayingly hand-rolled utf8 validation code
(c.f. _Py_DecodeUTF8Ex), and I can't really tell which one is more
correct.

I tried replacing lldb's isprint32() with a call to libc's iswprint():
this satisfied python, but broke emoji printing :|.

Now, I believe that lldb (and python too) ought to just call into some
battle-tested utf library, and that we shouldn't aim for compatibility
with python's strict unicode decoding mode until then.

FWIW I ran this test under an ASanified lldb hundreds of times but
didn't turn up any other issues.

rdar://62941711

Reviewers: JDevlieghere, jingham, shafik

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D79645
2020-05-11 09:53:48 -07:00
..
bindings Re-land "get rid of PythonInteger::GetInteger()" 2020-05-08 10:57:10 -07:00
cmake [lldb/CMake] Don't make PYTHON_RPATH a required variable. 2020-04-30 10:54:47 -07:00
docs [lldb/Docs] Add some more info about the test suite structure 2020-04-16 10:17:59 -07:00
examples [lldb] NFC: Fix trivial typo in comments, documents, and messages 2020-04-07 01:06:16 +09:00
include/lldb Complete breakpoint enable/disable/delete/modify with a list of breakpoint IDs 2020-05-11 15:21:51 +02:00
packages/Python [lldb/test] Make "inline" tests handle multiple statements at the same location 2020-05-11 16:37:34 +02:00
resources
scripts [lldb/Scripts] proc.returncode is set in proc.communicate 2020-04-21 11:30:15 -07:00
source [lldb] Add missing nullptr checks to AppleObjCRuntime::GetBacktraceThreadFromException 2020-05-11 16:02:51 +02:00
test [lldb/test] Fix for flakiness in TestNSDictionarySynthetic 2020-05-11 09:53:48 -07:00
third_party/Python/module [lldb] NFC: Fix trivial typo in comments, documents, and messages 2020-04-07 01:06:16 +09:00
tools [lldb/debugserver] Include TargetConditionals.h where needed 2020-05-09 10:12:17 -07:00
unittests Re-land "get rid of PythonInteger::GetInteger()" 2020-05-08 10:57:10 -07:00
utils [lldb/Utils] Serialize exit code in lldb-repro.py 2020-05-05 16:05:49 -07:00
.clang-format
.clang-tidy [lldb] Add .clang-tidy with customization to disable readability-identifier-naming 2020-03-09 12:50:28 -07:00
.gitignore
CMakeLists.txt [lldb/CMake] Only CMAKE_CFG_INTDIR if it's not '.' 2020-03-27 17:49:00 -07:00
CODE_OWNERS.txt [lldb][NFC] Cleanup mentions and code related to lldb-mi 2019-07-19 15:55:23 +00:00
LICENSE.TXT
use_lldb_suite_root.py