Page MenuHomeFreeBSD

Have builtins use ck* malloc functions.
AbandonedPublic

Authored by bdrewery on Dec 10 2019, 10:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 3, 7:40 PM
Unknown Object (File)
Feb 23 2024, 4:54 PM
Unknown Object (File)
Feb 23 2024, 4:54 PM
Unknown Object (File)
Feb 23 2024, 4:40 PM
Unknown Object (File)
Jan 8 2024, 7:05 PM
Unknown Object (File)
Dec 20 2023, 3:07 AM
Unknown Object (File)
Dec 13 2023, 11:32 PM
Unknown Object (File)
Oct 5 2023, 8:28 AM
Subscribers
None

Details

Reviewers
jilles
Summary

This will ensure interrupts are disabled and out-of-space is
handled gracefully.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28069
Build 26214: arc lint + arc unit

Event Timeline

jilles requested changes to this revision.Dec 11 2019, 7:40 PM

Adding INTOFF/INTON around malloc/free prevents unsafety due to interrupting the allocator, but does not prevent memory leaks or double frees due to the administration getting out of sync with the allocator (for example, if the INTON in ckmalloc() notices an interrupt, the allocated memory will leak). It would make more sense if ckmalloc/ckrealloc/ckfree merely asserted that INTON is in effect. I experimented with that earlier but did not follow through.

Also, the exception thrown by ckmalloc and ckrealloc if they fail is unlikely to be handled properly by code not specially designed for it.

What I have done in usr.bin/printf is to use normal strdup and check its return value, and to add INTOFF/INTON around most of the program under #ifdef SHELL. (This has negative effects if writing to standard output blocks.)

This revision now requires changes to proceed.Dec 11 2019, 7:40 PM