diff options
| author | jimingham <jingham@apple.com> | 2025-10-20 16:46:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-20 16:46:25 -0700 |
| commit | c9124a1b0853899bdd22d267124551ec4d720a23 (patch) | |
| tree | de5cee6fe6bb8c69bb78ce59d1e1bc3f9e7a7910 /clang/unittests/Format/FormatTestJava.cpp | |
| parent | cc88a3b8df21a04b688fccbdf239bd8329283100 (diff) | |
| download | llvm-c9124a1b0853899bdd22d267124551ec4d720a23.zip llvm-c9124a1b0853899bdd22d267124551ec4d720a23.tar.gz llvm-c9124a1b0853899bdd22d267124551ec4d720a23.tar.bz2 | |
Fix a potential use-after-free in StopInfoBreakpoint. (#163471)
StopInfoBreakpoint keeps a BreakpointLocationCollection for all the
breakpoint locations at the BreakpointSite that was hit. It is also
lives through the time a given thread is stopped, so there are plenty of
opportunities for one of the owning breakpoints to get deleted.
But BreakpointLocations don't keep their owner Breakpoints alive, so if
the BreakpointLocationCollection can live past when some code gets a
chance to delete an owner breakpoint, and then you ask that location for
some breakpoint information, it will access freed memory.
This wasn't a problem before PR #158128 because the StopInfoBreakpoint
just kept the BreakpointSite that was hit, and when you asked it
questions, it relooked up that list. That was not great, however,
because if you hit breakpoints 5 & 6, deleted 5 and then asked which
breakpoints got hit, you would just get 6. For that and other reasons
that PR changed to storing a BreakpointLocationCollection of the
breakpoints that were hit. That's better from a UI perspective but
caused this potential problem.
I fix it by adding a variant of the BreakpointLocationCollection that
also holds onto a shared pointer to the Breakpoints that own the
locations that were hit, thus keeping them alive till the
StopInfoBreakpoint goes away.
This fixed the ASAN assertion. I also added a test that works harder to
cause trouble by deleting breakpoints during a stop.
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
0 files changed, 0 insertions, 0 deletions
