Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Feb 1997 10:56:01 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        nao@sbl.cl.nec.co.jp (Naoki Hamada)
Cc:        freebsd-hackers@freefall.freebsd.org
Subject:   Re: MALLOC(3) writes to stderr...
Message-ID:  <199702251756.KAA26679@phaeton.artisoft.com>
In-Reply-To: <199702250755.QAA20017@sirius.sbl.cl.nec.co.jp> from "Naoki Hamada" at Feb 25, 97 04:55:47 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> Malloc(3) of 2.2-GAMMA writes error/warning messages to stderr. There
> is a daemon named jserver, which provides translations between
> Japanese characters, which does close stderr before opening its
> dictionary files. Sometimes jserver gets its dictionary file
> completely damaged by malloc's error/warning message.

malloc should use stderr itself, or it should user fileno(stderr)
whereever it is using a manifest 2.

If malloc is already doing this, then the error is in closing the
descriptor for stderr without closing the file pointer.  Output to
a closes descriptor or a closed file pointer should return an error
to the writer -- EBADF for a bad descriptor or stream (man 2 write,
man 2 close, man 2 fclose).  I suspect file streams are not correctly
invalidated on close in the current implementation.


> How should we deal with this anomaly? Yep, fixing jserver's memory
> allocation thoroughly might be the ultimate solution, but we need a
> practical solution for now. Must we change jserver to keep stderr open
> and to put error messages into /var/log/jserver.log or something? Or
> make malloc(3) keep silent?

Close stderr instead of closing descriptor 2.  Correct file pointer
using library routines, as necessary.


					Regards,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702251756.KAA26679>