This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [Process/NetBSD] Fix segfault when handling watchpoint
ClosedPublic

Authored by mgorny on Jun 25 2019, 1:53 PM.

Details

Summary

Fix the watchpoint/breakpoint code to search for matching thread entry
in m_threads explicitly rather than assuming that it will be present
at specified index. The previous code segfault since it wrongly assumed
that the index will match LWP ID which was incorrect even for a single
thread (where index was 0 and LWP ID was 1).

While fixing that off-by-one error would help for this specific task,
I believe it is better to be explicit in what we are searching for.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny created this revision.Jun 25 2019, 1:53 PM
labath accepted this revision.Jul 1 2019, 2:59 AM

LGTM. I don't know what Kamil is up to these days. It might be better to have him review patches like this, but if he's unable to do that, I'm happy to stamp them too...

This revision is now accepted and ready to land.Jul 1 2019, 2:59 AM
mgorny added a comment.Jul 1 2019, 3:09 AM

I'm going to ask Kamil to stamp those patches anyway but I always appreciate your advice wrt LLDB coding style and general integration. After all, we all want LLDB codebase to be more unified.

krytarowski accepted this revision.Jul 1 2019, 7:47 AM
krytarowski added inline comments.
lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
250 ↗(On Diff #206528)

We should always have a fallback and whenever we register an event for an unknown thread, we shall create it in place. There are potential races in the kernel that might lead to this order of reporting events. This is less likely for DB Registers, but still we shall be prepared for it just in case.

I'm fine to leave this for later once we will handle debuggees with multiple threads.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2019, 8:12 AM