From: John Spencer <maillist-musl@barfooze.de>
To: musl@lists.openwall.com
Subject: Re: NULL
Date: Wed, 09 Jan 2013 14:36:43 +0100 [thread overview]
Message-ID: <50ED726B.7010201@barfooze.de> (raw)
In-Reply-To: <20130109121832.GL4468@port70.net>
On 01/09/2013 01:18 PM, Szabolcs Nagy wrote:
> * John Spencer<maillist-musl@barfooze.de> [2013-01-09 12:02:29 +0100]:
>> at this point the issue in evince is not fixed, i still need to
>> create a patch based on their current git master, subscribe to their
>> ML, send them the patch and hope that they haven't changed their
>> mind.
> i think you are overcomplicating this issue
>
> this is clearly a violation of the standard and that's what
> you should tell to the maintainers:
>
> using NULL in the argument of variadic functions is ub both
> in c and c++
many developers don't care about the standard. they take the stance:
"works for me, if you want it patched then do it yourself and we'll
eventually merge"
> the problem is worse in c++ because it actually breaks code
> in practice with the usual c++ definition of NULL, in c the
> usual definition happens to work
>
>> so for me, there are 3 options how to deal with issue in the future:
>>
>> 1) go into the trouble of debugging all future C++ apps i will port,
> i think this issue should be catched with automated tools, not debugging:
> static code analyzer or runtime instrumentation of vararg functions
yes, as i proposed in 3)
>> (as a side note: when i googled for g_signal_emit, i found multiple
>> bug reports to multiple projects, of which the backtraces showed
>> exactly the kind of varargs UB that i encountered.
>> all of them were not fixed, but merely worked around. apparently the
>> developers of these projects didnt find the real cause of their
>> bugs.
>> this is not unlikely, as it is very hard to find out whats going on.
>> https://bugs.launchpad.net/compiz/+bug/932382
>> https://trac.transmissionbt.com/ticket/1135 ... )
> may be this should get a bit more publicity,
> it's an easy to fix bug
yes, once you know the details, it's easy to fix.
but when you don't, you'll have a hard time figuring out where the
segfault comes from.
i agree that this should get more publicity.
>> 2) change musl so it is compatible with those apps. this would mean:
>> #if defined(__GNUC__)&& defined(__cplusplus__)
>> #define NULL __null
> i think this is not needed, you can have a definition
> in c++ that "happens to work" just like the (void*)0
> in c:
>
> #define NULL 0L
yes, that'll work as well.
> but this is just a workaround, the bugs still need to be fixed
again, some ppl don't agree, even if you cite the standard.
i even heard things like "using a cast is ugly (or C'ish), we prefer NULL"
> (in c++11 we could use nullptr which has std::nullptr_t type
> which converts to (void*)0 in vararg context, but c++11 is not
> widely used yet)
>
>> 3) create some kind of code analysis tool that will scan C++ code
> i don't know any good open source static code analyzer for
> c and c++, maybe the clang based one can do the job
did you look at cppcheck ? i think this could be the right tool for the job.
if we raise awareness of the issue, i'm sure they'll add a check for this.
> i tried splint but that does not catch it
>
> catching null pointers in general can be tricky as 0 may be a
> valid argument to a variadic function and the code analyzer has
> no way to tell if it's meant to be a pointer or not
>
> but if NULL is used without a cast then that's an error both in
> c and c++ as both languages allow various different definitions
> of NULL which may have different size and representation in
> vararg context
>
>> i'm welcoming any comments on the issue. i'm especially interested
>> what the gentoo developers think.
> i wonder what makes them special :)
>
well, from what i heard on IRC they started to work on a musl port 2
weeks ago (but it got silent since...).
since they have likely more packages than sabotage (350) this issue
could cause them major pain.
next prev parent reply other threads:[~2013-01-09 13:36 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 11:02 NULL John Spencer
2013-01-09 12:18 ` NULL Szabolcs Nagy
2013-01-09 13:36 ` John Spencer [this message]
2013-01-12 6:32 ` NULL Rob Landley
2013-01-12 6:46 ` NULL Rich Felker
2013-01-12 7:15 ` NULL Luca Barbato
2013-01-12 13:33 ` NULL Rich Felker
2013-01-12 11:39 ` NULL Jens Staal
2013-01-09 13:09 ` NULL croco
2013-01-09 13:47 ` NULL John Spencer
2013-01-09 14:49 ` NULL croco
2013-01-09 14:42 ` NULL Luca Barbato
2013-01-09 14:47 ` NULL Rich Felker
2013-01-09 15:03 ` NULL Luca Barbato
2013-01-09 15:18 ` NULL John Spencer
2013-01-09 15:36 ` NULL Rich Felker
2013-01-09 21:11 ` NULL Rob
2013-01-09 21:53 ` NULL Szabolcs Nagy
2013-01-09 22:17 ` NULL Rob
2013-01-09 23:42 ` NULL Szabolcs Nagy
2013-01-12 6:56 ` NULL Rob Landley
2013-01-12 7:07 ` NULL Bobby Bingham
2013-01-12 13:31 ` NULL Rich Felker
2013-01-13 14:29 ` NULL Rob Landley
2013-01-13 14:56 ` NULL Luca Barbato
2013-01-13 16:29 ` NULL Rob Landley
2013-01-13 17:14 ` NULL Luca Barbato
2013-01-13 15:23 ` NULL Strake
2013-01-13 17:17 ` NULL Luca Barbato
2013-01-13 17:47 ` NULL Szabolcs Nagy
2013-01-13 19:46 ` NULL Rob Landley
2013-01-14 6:11 ` NULL Rich Felker
2013-01-14 8:45 ` musl as a framework to test applications' compatibility with POSIX (was: NULL) Vasily Kulikov
2013-01-14 14:03 ` Rich Felker
2013-01-14 14:30 ` Vasily Kulikov
2013-01-14 15:02 ` Szabolcs Nagy
2013-01-14 15:14 ` Rich Felker
2013-01-14 13:19 ` NULL Rob Landley
2013-01-12 5:56 ` NULL Rob Landley
2013-01-12 6:42 ` NULL Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50ED726B.7010201@barfooze.de \
--to=maillist-musl@barfooze.de \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).