From owner-freebsd-fs@FreeBSD.ORG Mon Apr 26 20:07:38 2010 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 2AFCE106564A for ; Mon, 26 Apr 2010 20:07:38 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-bw0-f216.google.com (mail-bw0-f216.google.com [209.85.218.216]) by mx1.freebsd.org (Postfix) with ESMTP id AA6C28FC17 for ; Mon, 26 Apr 2010 20:07:37 +0000 (UTC) Received: by bwz8 with SMTP id 8so11589465bwz.3 for ; Mon, 26 Apr 2010 13:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:to:subject:organization:from :date:message-id:user-agent:mime-version:content-type; bh=9J4aMy7DNUAtfuVdgPw6Md7CkEfbuaCfIZjJzNHDixM=; b=Fbh7EYhcIaCz3LsdYyDO4jA8AEFwyj+aSn6Pn/wubfE+F2OupUMGfl/ypFKoZOA7g8 DWoNH0H0+XEMwDFUztKzcUkiMY4LdfhKHAFKoUCoyePOV47uXdmesHiglcFXmOOJNYNF PU/Ar5NJasz3wixJ+smC1xMKnKXlmdK5iDcdE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=to:subject:organization:from:date:message-id:user-agent :mime-version:content-type; b=mqXGe/6Wcr81L9bSBPRfCPoqAIzPaIRxoJD7s46DyaKtvY2f8dG+lEoWBzxTzn3vXZ e2oed3ctL0+w/1HuJ2LpFpdfRLqj+1lxXLckjupG60D9sMlk3cG6WryIs1QjOx+XPKlL jAV5nU5folQS97wEQCrz1WGszrOOcF94OEWiE= Received: by 10.204.22.16 with SMTP id l16mr2978493bkb.186.1272312453641; Mon, 26 Apr 2010 13:07:33 -0700 (PDT) Received: from localhost ([95.69.163.27]) by mx.google.com with ESMTPS id 16sm1609951bwz.13.2010.04.26.13.07.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Apr 2010 13:07:32 -0700 (PDT) To: freebsd-fs Organization: Home From: Mikolaj Golub Date: Mon, 26 Apr 2010 23:07:31 +0300 Message-ID: <86iq7ex9j0.fsf@kopusha.onet> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: hastd segfaults reading metadata from not initialized provider 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: Mon, 26 Apr 2010 20:07:38 -0000 --=-=-= Hi, When configuring a new provider if one forgets to do hastctl create tank before hastctl role primary tank the worker core dumps on reading metadata: (gdb) bt #0 strcmp () at /usr/src/lib/libc/i386/string/strcmp.S:61 #1 0x0804fa18 in metadata_read (res=0x284cb600, openrw=true) at /usr/src/sbin/hastd/metadata.c:120 #2 0x080570ac in init_local (res=0x284cb600) at /usr/src/sbin/hastd/primary.c:425 #3 0x08057f88 in hastd_primary (res=0x284cb600) at /usr/src/sbin/hastd/primary.c:754 #4 0x0804e270 in child_exit () at /usr/src/sbin/hastd/hastd.c:145 #5 0x0804edd1 in main_loop () at /usr/src/sbin/hastd/hastd.c:389 #6 0x0804f3d8 in main (argc=0, argv=0xbfbfed84) at /usr/src/sbin/hastd/hastd.c:520 Current language: auto; currently asm (gdb) fr 1 #1 0x0804fa18 in metadata_read (res=0x284cb600, openrw=true) at /usr/src/sbin/hastd/metadata.c:120 120 if (strcmp(str, res->hr_name) != 0) { Current language: auto; currently c (gdb) list 115 ebuf_free(eb); 116 goto fail; 117 } 118 119 str = nv_get_string(nv, "resource"); 120 if (strcmp(str, res->hr_name) != 0) { 121 pjdlog_error("Provider %s is not part of resource %s.", 122 res->hr_localpath, res->hr_name); 123 nv_free(nv); 124 goto fail; (gdb) p str $1 = 0x0 In the attached patch the check for str is added so we would have a termination with the error message instead of a core dump: Apr 26 22:46:06 hasta hastd: [tank] (primary) Metadata read from /dev/ad6 is invalid. Apr 26 22:46:06 hasta hastd: [tank] (primary) Worker process failed (pid=6196, status=66). -- Mikolaj Golub --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hastd.metadata.c.patch Index: sbin/hastd/metadata.c =================================================================== --- sbin/hastd/metadata.c (revision 207245) +++ sbin/hastd/metadata.c (working copy) @@ -117,6 +117,12 @@ metadata_read(struct hast_resource *res, bool open } str = nv_get_string(nv, "resource"); + if (str == NULL) { + pjdlog_error("Metadata read from %s is invalid.", + res->hr_localpath); + nv_free(nv); + goto fail; + } if (strcmp(str, res->hr_name) != 0) { pjdlog_error("Provider %s is not part of resource %s.", res->hr_localpath, res->hr_name); --=-=-=--