From owner-freebsd-hackers@FreeBSD.ORG Mon May 16 11:11:45 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 84CFD16A4CE for ; Mon, 16 May 2005 11:11:45 +0000 (GMT) Received: from smtp2.dnainternet.net (smtp2.dnainternet.net [62.240.72.111]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A30F43D8B for ; Mon, 16 May 2005 11:11:45 +0000 (GMT) (envelope-from juho.vuori@kepa.fi) Received: from 217-140-230-13.adsl-net.finnetcom.net ([217.140.230.13]:54436 "EHLO [217.140.230.13]" TLS-CIPHER: ) by smtp2.dnainternet.net with ESMTP id S1228739AbVEPLLn (ORCPT ); Mon, 16 May 2005 14:11:43 +0300 Message-ID: <42887FEE.3000705@kepa.fi> Date: Mon, 16 May 2005 14:11:42 +0300 From: Juho Vuori User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050512) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Bug in devinfo or something wrong with me? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2005 11:11:45 -0000 The below included simple program reliably printfs "error 4\n" on 5.4-RELEASE. Am I understanding something wrong or is this a bug in libdevinfo? To continue on this however, if you put say sleep(5) between devinfo_free() and the second devinfo_init() and manage to change the device configuration during the sleep (tested with pluggin in/out a USB memory), the program terminates with no errors. I've run into other oddities with devinfo as well, but in much more complex situations so they might just as well be variations of this simple example. Juho /* save this as test.c and compile: * cc -o test test.c -ldevinfo */ #include #include int main () { struct devinfo_dev *root; if (devinfo_init()) { printf("error 1\n"); return -1; } if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) { printf("error 2\n"); return -1; } devinfo_free(); if (devinfo_init()) { printf("error 3\n"); return -1; } if ((root = devinfo_handle_to_device(DEVINFO_ROOT_DEVICE)) == 0) { printf("error 4\n"); return -1; } devinfo_free(); printf("no errors\n"); return 0; }