Page MenuHomeFreeBSD

kern_malloc: add ability to track down consistent double-free address
AbandonedPublic

Authored by bz on Nov 28 2022, 4:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 22 2023, 12:42 PM
Unknown Object (File)
Sep 30 2023, 7:14 PM
Unknown Object (File)
Sep 21 2023, 10:20 PM
Unknown Object (File)
Jul 10 2023, 10:59 PM
Unknown Object (File)
Jan 8 2023, 3:47 PM
Unknown Object (File)
Jan 8 2023, 1:51 PM
Unknown Object (File)
Jan 7 2023, 12:19 PM
Unknown Object (File)
Dec 2 2022, 10:20 AM
Subscribers

Details

Reviewers
jhb
markj
kib
Summary

I had a consistent address for double-free of a driver in a test
environment and needed a quick way to track down both calls (well the
first one). Given dtrace is not much help with an (almost immediate)
panic I added sysctls under MALLOC_DEBUG that took the address and
either printed or paniced when we tried to free the address and was done
in a few minutes.

While this is a thing which could probably be done otherwise (gdb + Xwatch)
it seems a case people hit once in a while. Unless you think this can
be useful (possibly for other things as well) I have no intentions to
put it into the tree but wanted to have it up somewhere before it goes
out of my tree again.

On the other hand I'll be more than happy to learn about 5 more ways to
do this for a lot of people to possibly benefit from the collection of
debugging knowledge.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 48520
Build 45406: arc lint + arc unit

Event Timeline

bz requested review of this revision.Nov 28 2022, 4:09 PM

For things that go boom I like to use KTR rather than printf for things that occur often as then I can get the most recent history (which is what you normally want) from the crashdump via ktrdump or from DDB via show ktr.