From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Stekloff Date: Wed, 15 Dec 2004 16:40:04 +0000 Subject: Re: Bug#285281: core dump on amd64 (gcc-3.4) Message-Id: <1103128803.3033.4.camel@localhost.localdomain> List-Id: References: <20041215085045.GA4444@wonderland.linux.it> In-Reply-To: <20041215085045.GA4444@wonderland.linux.it> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Wed, 2004-12-15 at 05:27, Kay Sievers wrote: > On Wed, 2004-12-15 at 09:50 +0100, Marco d'Itri wrote: > > clsdev->directory is NULL, is this a bug in libsysfs or udev? > > Apparently this only happens on amd64. This is definitely a libsysfs bug. > > ----- Forwarded message from martin-deb@zero-based.org ----- > > > #0 0x0000000000403024 in sysfs_get_classdev_attr (clsdev=0x518260, name=0x40dcac "dev") at libsysfs/sysfs_class.c:643 > > 643 if (clsdev->directory->subdirs = NULL) > > (gdb) backtrace > > It is caused by the vc class behavior, to emit events on every open() > and close(). We get a lot of events on bootup for every vc device, cause > it is several times reopened. This causes the sysfs-dir to go away while > the device is opened in libsysfs. This simple test program: > > #include > #include > #include > #include > #include > #include > #include > > #include "libsysfs/sysfs/libsysfs.h" > > > int main(int argc, char *argv[], char *envp[]) > { > struct sysfs_class_device *class_dev; > struct sysfs_attribute *attr; > > mkdir("test-sys", 0775); > mkdir("test-sys/class", 0775); > mkdir("test-sys/class/test", 0775); > > setenv("SYSFS_PATH", "test-sys", 1); > > printf("open\n"); > class_dev = sysfs_open_class_device_path("test-sys/class/test"); > printf("%p\n", class_dev); > > printf("rmdir\n"); > rmdir("test-sys/class/test"); > > printf("read attr\n"); > attr = sysfs_get_classdev_attr(class_dev, "dev"); > } > > segfaults every time: > [kay@pim udev.kay]$ gcc -g -I libsysfs/sysfs -I libsysfs -o bug bug.c libsysfs/sysfs.a > [kay@pim udev.kay]$ ./bug > open > 0x804f0d8 > rmdir > read attr > Segmentation fault > > > This seems to fix it: > > === libsysfs/sysfs_class.c 1.11 vs edited ==> --- 1.11/libsysfs/sysfs_class.c 2004-10-20 05:15:26 +02:00 > +++ edited/libsysfs/sysfs_class.c 2004-12-15 14:20:13 +01:00 > @@ -640,6 +640,9 @@ > return cur; > } > > + if (clsdev->directory = NULL) > + return NULL; > + > if (clsdev->directory->subdirs = NULL) > if ((sysfs_read_dir_subdirs(clsdev->directory)) != 0 || > clsdev->directory->subdirs = NULL) We wrongly assume that the directory is there or is opened when sysfs_get_classdev_attributes() runs prior to this. We'll apply this patch to the tree. Thanks, Dan > > Thanks, > Kay > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net > Linux-hotplug-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel