I caught this while running the testsuite against lldb built with address sanitizer (ASAN) enabled - it found one problem when running the TestLinuxCore.py test. The ELFLinuxPrPsInfo structure has two fixed width strings in it, pr_fname (16 chars) and pr_psargs (80 chars). They are not required to be nul (\0) terminated, and in the case of ppc64le, pr_fname is not -
(lldb) p prpsinfo
(ELFLinuxPrPsInfo) $1 = {
pr_fname = { [0] = 'l' [1] = 'i' [2] = 'n' [3] = 'u' [4] = 'x' [5] = '-' [6] = 'p' [7] = 'p' [8] = 'c' [9] = '6' [10] = '4' [11] = 'l' [12] = 'e' [13] = '.' [14] = 'o' [15] = 'u' }
When we copy this into a std::string,
thread_data.name = prpsinfo.pr_fname;
the read goes off the end of the array. It goes into the next element on the structure, pr_psargs, so it's unlikely to crash, but it's an easy one to fix so I think we should.
TestLinuxCore.py's do_test() could also get passed in the expected thread name and verify that it was set correctly), that would have caught this without using ASAN. But given that ASAN did catch it, I'm pretty happy with it as-is.