rfc: free and errno
Hi List
free() is generaly assumed not to modify errno.
Lately there was a bugfix posting on the busybox mailing list, because:
"musl libc's mallocing free() may modify errno if kernel does not support MADV_FREE which causes echo to echo with error when it shouldn't."
In future it seems that POSIX with require free() not to change errno.
after much soul searching i have still no idea if that should be documented in the free(3) man page. Any comments ?
re,
wh
Hello Walter,
Thanks for raising this.
Quoted 9 lines · Walter Harms
Hi List
free()is generaly assumed not to modify errno.Lately there was a bugfix posting on the busybox mailing list, because:
"musl libc's mallocing
free()may modify errno if kernel does not supportMADV_FREEwhich causes echo to echo with error when it shouldn't."
URL please.
Quoted 1 line
In future it seems that POSIX with require
free()not to change errno.
The statement you make in the preceding sentence is useful information, but you could save other people a lot of time searching if you provided a reference:
https://www.austingroupbugs.net/view.php?id=385#c713
Quoted 2 lines
after much soul searching i have still no idea if that should be documented in the free(3) man page. Any comments ?
Probably it should be documented. Did you have a suggestion for the text?
Thanks,
Michael
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
* Michael Kerrisk <[email protected]>, 2021-02-06, 10:49:
Quoted 8 lines · Walter Harms
Quoted 5 lines
free()is generaly assumed not to modify errno.Lately there was a bugfix posting on the busybox mailing list, because:
"musl libc's mallocing
free()may modify errno if kernel does not supportMADV_FREEwhich causes echo to echo with error when it shouldn't."URL please.
http://lists.busybox.net/pipermail/busybox/2021-January/088491.html probably.
glibc's free() also can set errno in some circumstances:
https://sourceware.org/bugzilla/show_bug.cgi?id=17924
Signature · 1 line
Jakub Wilk