From owner-freebsd-fs@FreeBSD.ORG Sun Jun 28 20:14:30 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F849106566C; Sun, 28 Jun 2009 20:14:30 +0000 (UTC) (envelope-from serenity@exscape.org) Received: from ch-smtp01.sth.basefarm.net (ch-smtp01.sth.basefarm.net [80.76.149.212]) by mx1.freebsd.org (Postfix) with ESMTP id 2DC5F8FC1E; Sun, 28 Jun 2009 20:14:30 +0000 (UTC) (envelope-from serenity@exscape.org) Received: from c83-253-252-234.bredband.comhem.se ([83.253.252.234]:43435 helo=mx.exscape.org) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.69) (envelope-from ) id 1ML0lX-0006VX-5y; Sun, 28 Jun 2009 22:14:21 +0200 Received: from [192.168.1.5] (macbookpro [192.168.1.5]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mx.exscape.org (Postfix) with ESMTPSA id 6A20F61C15; Sun, 28 Jun 2009 22:14:19 +0200 (CEST) Message-Id: <09277772-9C54-4AE6-A147-CB6A4ED38C48@exscape.org> From: Thomas Backman To: FreeBSD current In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Sun, 28 Jun 2009 22:14:16 +0200 References: <08D1E6DF-89D3-4887-9234-C3DB9164D794@exscape.org> <20090514133017.362075dhcdy7o2bs@webmail.leidinger.net> <7CD27FF0-CBFA-48B7-9E18-763D8C3ED9B8@exscape.org> <4A0C9B0C.4050403@jrv.org> X-Mailer: Apple Mail (2.935.3) X-Originating-IP: 83.253.252.234 X-Scan-Result: No virus found in message 1ML0lX-0006VX-5y. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1ML0lX-0006VX-5y 208144b44b36969805de88ad507ee025 Cc: freebsd-fs@freebsd.org Subject: Re: zfs send -R segfault, anyone else? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 20:14:31 -0000 On May 15, 2009, at 11:30 AM, Thomas Backman wrote: > > On May 15, 2009, at 12:28 AM, James R. Van Artsdalen wrote: > >> Thomas Backman wrote: >>> [root@chaos ~]# zfs send -R -I $OLD tank@$NOW > diff-snap >>> [root@chaos ~]# cat diff-snap | zfs recv -Fvd slave >>> Segmentation fault: 11 (core dumped) >>> >>> Same kinda backtrace, but what's up with strcmp()? >>> I suppose the issue stems from libzfs, and is not within libc: >> >> Different problem The SIGSEGV is happening in strcmp because it is >> called with strcmp(0,0) >> and tries to dereference address -4 (probably another bug itself). >> >> This hack gets around the issue but someone familiar with this >> needs to >> decide the correct action. >> >> The first change is actually unrelated (a sorry attempt at fixing the >> previous zfs send bug). >> >> The last change may be unnecessary as that case may never happen >> unless >> the pool can be renamed? >> >> [... patch ...] > > Thanks! This list is pretty impressive. :) > I can't validate how correct the fix is, considering my lacking > knowledge in C (I know the basics, but kernel/related programming? > no way!), but I CAN say that it appears to work just fine! > > Regards, > Thomas > Any news on this? The bug's been around for a long time, and a fix has been around for at least 1.5 months now, and AFAIK the bug still lives. The patch, again (I can't vouch for its correctness, but I can certainly say that it works just fine *for me*) follows. Regards, Thomas Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c =================================================================== --- cddl/contrib/opensolaris/lib/libzfs/common/ libzfs_sendrecv.c (revision 194851) +++ cddl/contrib/opensolaris/lib/libzfs/common/ libzfs_sendrecv.c (working copy) @@ -239,6 +239,8 @@ char *propname = nvpair_name(elem); zfs_prop_t prop = zfs_name_to_prop(propname); nvlist_t *propnv; + if (prop == ZPROP_INVAL) + continue; if (!zfs_prop_user(propname) && zfs_prop_readonly(prop)) continue; @@ -1126,7 +1128,7 @@ uint64_t originguid = 0; uint64_t stream_originguid = 0; uint64_t parent_fromsnap_guid, stream_parent_fromsnap_guid; - char *fsname, *stream_fsname; + char *fsname, *stream_fsname, *p1, *p2; nextfselem = nvlist_next_nvpair(local_nv, fselem); @@ -1295,10 +1297,13 @@ "parentfromsnap", &stream_parent_fromsnap_guid)); /* check for rename */ + p1 = strrchr(fsname, '/'); + p2 = strrchr(stream_fsname, '/'); + if ((stream_parent_fromsnap_guid != 0 && stream_parent_fromsnap_guid != parent_fromsnap_guid) || - strcmp(strrchr(fsname, '/'), - strrchr(stream_fsname, '/')) != 0) { + (p1 != NULL && p2 != NULL && strcmp (p1, p2) != 0) || + ((p1 == NULL) ^ (p2 == NULL))) { nvlist_t *parent; char tryname[ZFS_MAXNAMELEN]; @@ -1317,7 +1322,7 @@ VERIFY(0 == nvlist_lookup_string(parent, "name", &pname)); (void) snprintf(tryname, sizeof (tryname), - "%s%s", pname, strrchr(stream_fsname, '/')); + "%s%s", pname, p2 ? p2 : ""); } else { tryname[0] = '\0'; if (flags.verbose) {