>Number: 144307 >Category: misc >Synopsis: ENOENT set unnecessarily under certain circumstances when >malloc is called / fails >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 26 01:20:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: RELENG_8 >Organization: Cisco Systems, Inc >Environment: FreeBSD garrcoop-fbsd.cisco.com 8.0-STABLE FreeBSD 8.0-STABLE #2: Wed Feb 3 16:57:07 PST 2010 garrc...@garrcoop-fbsd.cisco.com:/usr/obj/usr/src/sys/LAPPY_X86 i386 >Description: On systems where /etc/malloc.conf isn't present, some failures syscalls like read will fail incorrectly with ENOENT because the file doesn't exist, and thus output via errx will be incorrect, like shown from the following disklabel output:
1+0 records in 1+0 records out 512 bytes transferred in 0.000054 secs (9502140 bytes/sec) disklabel: /dev/md1 read: No such file or directory This can be reproduced as follows (yes, the dd command are stat commands are wrong -- I know that...) if malloc.conf is not present: dd if=/dev/zero of=$output_file conv=sparse bs=$(stat -f '%z' "$input_directory") count=1 mdconfig -a -t vnode -u ${md_num} -f "$output_file" disklabel -rw /dev/md${md_num} auto Once malloc.conf is present... sudo ln -s M /etc/malloc.conf # ... 1+0 records in 1+0 records out 512 bytes transferred in 0.000054 secs (9460280 bytes/sec) disklabel: /dev/md1 read: Unknown error: 0 >How-To-Repeat: dd if=/dev/zero of=foo conv=sparse bs=512 count=1 mdconfig -a -t vnode -u 1 -f foo disklabel -rw /dev/md1 auto >Fix: 1. Set malloc.conf to a valid value as per malloc(3). 2. Apply attached patch. Patch attached with submission follows: Index: lib/libc/stdlib/malloc.c =================================================================== --- lib/libc/stdlib/malloc.c (revision 204027) +++ lib/libc/stdlib/malloc.c (working copy) @@ -5408,6 +5408,11 @@ /* Get runtime configuration. */ switch (i) { case 0: + /* + * Make sure that a valid errno code doesn't get wiped + * out if malloc.conf doesn't exist. + */ + int saved_errno = errno; if ((linklen = readlink("/etc/malloc.conf", buf, sizeof(buf) - 1)) != -1) { /* @@ -5421,6 +5426,7 @@ buf[0] = '\0'; opts = buf; } + errno = saved_errno; break; case 1: if (issetugid() == 0 && (opts = >Release-Note: >Audit-Trail: >Unformatted: _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"