Bug#285281: core dump on amd64 (gcc-3.4)
clsdev->directory is NULL, is this a bug in libsysfs or udev? Apparently this only happens on amd64.
----- Forwarded message from [email protected] -----
Subject: Bug#285281: core dump on amd64 (gcc-3.4)
Reply-To: [email protected], [email protected]
From: [email protected]
To: [email protected]
Cc: Harald Dunkel <[email protected]>
Quoted 7 lines · Marco d'Itri
Quoted 2 lines · Harald Dunkel
There seems to be something wrong with udev at least on amd64 (gcc-3.4).
Please do your best to get a stack trace, possibly from the unstripped binary.
I see the same behavior on amd64 with gcc-3.3. Here is a stacktrace:
GNU gdb 6.3-debian
[...]
Core was generated by `udev vc'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux-x86-64.so.2...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
#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
#0 0x0000000000403024 in sysfs_get_classdev_attr (clsdev=0x518260, name=0x40dcac "dev") at libsysfs/sysfs_class.c:643 #1 0x000000000040904e in get_major_minor (class_dev=0x0, udev=0x7fbffff330) at udev_add.c:57 #2 0x0000000000409874 in udev_add_device (udev=0x7fbffff330, class_dev=0x518260) at udev_add.c:287 #3 0x0000000000402009 in main (argc=2, argv=0x7fbffffdb8, envp=0x0) at udev.c:197
(gdb) print *clsdev
$1 = {name = "vcs1", '\0' <repeats 45 times>, classname = "vc", '\0' <repeats 47 times>,
path = "/sys/class/vc/vcs1", '\0' <repeats 236 times>, parent = 0x0, sysdevice = 0x0, driver = 0x0, directory = 0x0}
Martin
----- End forwarded message -----
Signature · 13 lines
ciao, | Marco | [9803 vebcDBN29Lxms] ------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 1 line · Marco d'Itri
clsdev->directoryis NULL, is this a bug in libsysfs or udev?
From further discussions on the debian-amd64 mailing list I understand that the bug was introduced in 047 or 048.
Signature · 2 lines
ciao, | Marco | [9811 stQz.IcAJS5Nc]
Quoted 8 lines · Marco d'Itri
clsdev->directoryis NULL, is this a bug in libsysfs or udev? Apparently this only happens on amd64.----- Forwarded message from [email protected] -----
#0
0x0000000000403024insysfs_get_classdev_attr(clsdev=0x518260, name=0x40dcac "dev") atlibsysfs/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 <stdio.h>
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#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) 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · Kay Sievers
Quoted 2 lines · Marco d'Itri
clsdev->directoryis NULL, is this a bug in libsysfs or udev? Apparently this only happens on amd64.
This is definitely a libsysfs bug.
Quoted 59 lines
Quoted 5 lines
----- Forwarded message from [email protected] -----
#0
0x0000000000403024insysfs_get_classdev_attr(clsdev=0x518260, name=0x40dcac "dev") atlibsysfs/sysfs_class.c:643
643 if (clsdev->directory->subdirs= NULL)
(gdb) backtraceIt is caused by the vc class behavior, to emit events on every
open()andclose(). 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 <
stdio.h>
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>#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 bugbug.clibsysfs/sysfs.a [kay@pim udev.kay]$ ./bug
open
0x804f0d8
rmdir
read attr
Segmentation faultThis seems to fix it:
===
libsysfs/sysfs_class.c1.11 vs edited ==> ---1.11/libsysfs/sysfs_class.c2004-10-20 05:15:26 +02:00
+++edited/libsysfs/sysfs_class.c2004-12-15 14:20:13 +01:00
Review line 648
Quoted 9 lines
(quoted diff) +3
-0@@ -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
Quoted 6 lines
Thanks,
Kay
Quoted 10 lines
-------------------------------------------------------
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
[email protected]
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 21 lines · Kay Sievers
Quoted 8 lines · Marco d'Itri
clsdev->directoryis NULL, is this a bug in libsysfs or udev? Apparently this only happens on amd64.----- Forwarded message from [email protected] -----
#0
0x0000000000403024insysfs_get_classdev_attr(clsdev=0x518260, name=0x40dcac "dev") atlibsysfs/sysfs_class.c:643
643 if (clsdev->directory->subdirs= NULL)
(gdb) backtraceIt is caused by the vc class behavior, to emit events on every
open()andclose(). 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:This seems to fix it:
===
libsysfs/sysfs_class.c1.11 vs edited ==> ---1.11/libsysfs/sysfs_class.c2004-10-20 05:15:26 +02:00
+++edited/libsysfs/sysfs_class.c2004-12-15 14:20:13 +01:00
Review line 648
Quoted 9 lines
(quoted diff) +3
-0@@ -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)
Thanks for the patch Kay. I have applied this to my tree too.
Thanks,
Ananth
-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 24 lines · Ananth N Mavinakayanahalli
Quoted 23 lines · Kay Sievers
Quoted 8 lines · Marco d'Itri
clsdev->directoryis NULL, is this a bug in libsysfs or udev? Apparently this only happens on amd64.----- Forwarded message from [email protected] -----
#0
0x0000000000403024insysfs_get_classdev_attr(clsdev=0x518260, name=0x40dcac "dev") atlibsysfs/sysfs_class.c:643
643 if (clsdev->directory->subdirs= NULL)
(gdb) backtraceIt is caused by the vc class behavior, to emit events on every
open()andclose(). 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:This seems to fix it:
===
libsysfs/sysfs_class.c1.11 vs edited ==> > ---1.11/libsysfs/sysfs_class.c2004-10-20 05:15:26 +02:00
+++edited/libsysfs/sysfs_class.c2004-12-15 14:20:13 +01:00(quoted diff) +0
-0@@ -640,6 +640,9 @@ return cur; }
Quoted 9 lines
Review line 648
Quoted 7 lines
(quoted diff) +3
-0+ if (clsdev->directory = NULL) + return NULL; + if (clsdev->directory->subdirs = NULL) if ((sysfs_read_dir_subdirs(clsdev->directory)) != 0 || clsdev->directory->subdirs = NULL)Thanks for the patch Kay. I have applied this to my tree too.
Nice, thanks. Greg, please pull it from:
bk://vrfy.bkbits.net/udev
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 4 lines · Kay Sievers
Quoted 1 line
Thanks for the patch Kay. I have applied this to my tree too.
Nice, thanks. Greg, please pull it from:
bk://vrfy.bkbits.net/udev
Pulled from, thanks for applying this, and the other patches.
greg k-h
-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel