This will ensure interrupts are disabled and out-of-space is
handled gracefully.
Details
Diff Detail
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 28069 Build 26214: arc lint + arc unit
Event Timeline
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.)