Bjoern A. Zeeb wrote:
On Sun, 26 Jul 2009, Kostik Belousov wrote:
On Sat, Jul 25, 2009 at 09:06:34PM -0400, Michael Butler wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jamie Gritton wrote:
Michael Butler wrote:
i...@aaron:/home/imb> sudo jexec 5 tcsh
jexec: Unable to parse jail ID.: No such file or directory
The symptom in jexec can be fixed by this little patch:
Index: usr.sbin/jexec/jexec.c
===================================================================
--- usr.sbin/jexec/jexec.c (revision 195879)
+++ usr.sbin/jexec/jexec.c (working copy)
@@ -248,6 +248,7 @@
if (argc < 2)
usage();
if (strlen(argv[0]) > 0) {
+ errno = 0;
jid = (int)strtol(argv[0], NULL, 10);
if (errno)
err(1, "Unable to parse jail ID.");
Thanks - this certainly cures the effect.
But the broader problem is malloc. It's leaving errno set to
ENOENT when /etc/malloc.conf doesn't exist. This seems like
wrong behavior to me.
Seems like a POLA violation to me,
No, this is how errno generally work, it is not changed if no error
happens.
I haven't really understood which part, when and why would set the errno in
first place so that it would still be there? Is it something in jexec
that gets the errno in first place or is it something internal to
malloc that sets it returns successfully and doesn't clear it?
The POLA violation is in malloc - it sets errno even when there was no
error. The allocation succeeded and a pointer was returned, yet errno
was set to ENOENT (not even an error malloc should be able to return).
The fact that malloc looks for an optional config file and doesn't find
one shouldn't be relayed back to the caller in errno. If
/etc/malloc.conf doesn't exist, it should either clear errno after that,
or perhaps restore its previous value. There's also a
getenv("MALLOC_OPTIONS") that can similarly set errno.
Perhaps this has all been gone over before and I missed it (this is from
code that's been stable since 2006), so I wouldn't want to just rush in
and fix malloc. Maybe this general principle has already been discussed
and my viewpoint lost. But if not, it's my opinion that malloc is
acting badly and needs a change.
In the meantime, I have no problem with errno not being cleared in
strtol, and the patch to jexec is correct (though strictly speaking it
shouldn't be necessary since we "know" errno has not yet been set).
- Jamie
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"