[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#757835: nfs-kernel-server: after update 1.2.8-6->1.2.8-8 rpc.mountd starts crashing



On Tue, 2014-08-12 at 19:23 +0100, Ben Hutchings wrote:
> On Tue, 2014-08-12 at 09:05 -0700, Steve Langasek wrote:
> [...]
> > Matthias, could you please have a look at the below test case?  We have a
> > regression in the latest nfs-kernel-server build, which appears to be caused
> > by a gcc-4.9 bug.
> > 
> > Should I work around this in nfs-utils, or is a quick fix possible in
> > gcc-4.9?
> > 
> > > char buf[100];
> > > 
> > > void
> > > add_name(char *old)
> > > {
> > > 	char *cp = old;
> > > 
> > > 	while (cp && *cp) {
> > > 		cp++;
> > > 	}
> > > 	__builtin_strncpy(buf, old, cp-old);
> [...]
> 
> So far as I know (haven't checked the latest standard), pointer
> subtraction has undefined behaviour unless both operands point into (or
> one beyond) the same array.  As this is not true of null pointers, the
> compiler may infer that old can't be null, so cp can't be null, so there
> is no need to check whether it is.
> 
> I.e. this is a bug in nfs-utils, not the compiler.

By the way, in case there are similar bugs elsewhere in nfs-utils, it
may be sensible to work around this with the compiler option
-fno-delete-null-pointer-checks.

Ben.

-- 
Ben Hutchings
Humans are not rational beings; they are rationalising beings.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: