Hi Daniel, Mike,

thanks for your analysis, which is pretty much complete from my perspective.

In the functions intercepted by libfaketime, we need to ensure that the "offending" parameter is indeed non-NULL, and although this may be the enforced case in the future when everything on the system is gcc6-compiled, we can't rely on that assumption in a cross-platform way at the moment. Other ways of handling gcc6 and __THROW__nonnull would require gcc6-specific code in each of the stat()-family functions, so suppressing the check using -Wno-nonnull-compare is the best solution for the moment. Thanks for the patch!


Cheers,
Wolfgang
Daniel Kahn Gillmor <mailto:d...@fifthhorseman.net>
7 July 2016 at 19:19
Hi Mike--

Thanks for this analysis and the proposed fix! I think the issue here
is that faketime is providing a wrapper around stat(), and stat itself
has undefined behavior if it was passed a NULL pointer.

So arguably, in normal code, we would propagate the "undefined behavior"
out through faketime's wrapper of stat.

However, faketime's wrapper is called through LD_PRELOAD, so no compiler
would notice such a marking anyway.

So at the moment, i think your conclusion is the right workaround for
debian, and i'll upload something like it shortly.

However, upstream (Hi Wolfgang on Cc!) might view this differently.
Wolfgang, do you want to propose a different way to make faketime build
cleanly with GCC 6?

--dkg
Mike Gerow <mailto:ge...@mgerow.com>
7 July 2016 at 11:59
Proposing this patch to just disable the warning. Not super familiar
with the general policies around this, though.

---
debian/changelog | 7 +++++++
debian/rules | 6 ++++++
2 files changed, 13 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 9cb8901..535de0c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+faketime (0.9.6-4.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Disable the nonnull-compare flag for faketime.
+
+ -- Mike Gerow <ge...@mgerow.com> Thu, 07 Jul 2016 11:36:54 +0200
+
faketime (0.9.6-4) unstable; urgency=medium

* link to libfaketime's README from faketime's doc dir (thanks, Ximin
diff --git a/debian/rules b/debian/rules
index cf3813a..1cd0399 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,6 +5,12 @@

export DEB_CFLAGS_MAINT_APPEND=-DMULTI_ARCH

+# GCC 6 includes a warning for checking if a variable nonnull if it's been +# tagged that passing a NULL value creates undefined behavior. Ignore this for +# faketime since the compilation units that define this for it are in libc,
+# which may or may not have these flags.
+export CFLAGS+=-Wno-nonnull-compare
+
# make sure dh_makeshlibs does not modify post{inst,rm} scripts:
# (avoids lintian's postinst-has-useless-call-to-ldconfig)
override_dh_makeshlibs:

Reply via email to