On Tue, 30 Aug 2011, Joerg-Cyril.Hoehle@t-systems.com wrote:
André Hentschel suggested:
Should stop the crash on Solaris and maybe others
- trace("parent_data = (%p) -> %s\n", parent_data, (char *)parent_data);
- trace("parent_data (%p) -> %s\n", parent_data, parent_data ? (char *)parent_data : "(null)");
This is sooo backwards. You don't want to try and find all places where (null) may be printed. I remember seeing (null) in logs here and there, so you're telling us that turning on Wine logs in Solaris can randomly crash Wine because it crashes on printf("%s", NULL)?
I'm very surprised. I thought Solaris was one of the first machines - decades ago - where I observed "(null)" for NULL. (Or is that really glibc only?)
It appears this was quite extensively debated on the OpenSolaris mailing lists: http://osdir.com/ml/os.solaris.opensolaris.devel/2006-07/msg00026.html
That's just to say that no, Solaris (unlike SunOS 4) never allowed a NULL pointer argument to '%s' (not that we should reenact the debate here). One of the recommendations in that thread is to define something like this where needed:
#define SAFESTR(s) ((s) ? (s) : "(null)")
The Single UNIX Specification does not say what should happen in this case. To me that means we should not depend on '%s' accepting NULL pointers. http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html