Opened 19 years ago
Closed 19 years ago
#1604 closed defect (fixed)
cfdisk doesn't run
Reported by: | Owned by: | Matthew Burgess | |
---|---|---|---|
Priority: | lowest | Milestone: | |
Component: | Book | Version: | Branch_GCC4 |
Severity: | normal | Keywords: | |
Cc: |
Description
cfdisk (in the util-linux package) quits with a segmentation fault whenever I try to run it.
Attachments (1)
Change History (31)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
I just booted back into my GCC4 system and recompiled util-linux just to double-check. I didn't keep track of which book version I used, but I finished building the system on 7/28/05...
root@chris:/usr/src# gcc --version gcc (GCC) 4.0.1 Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@chris:/usr/src# cat /proc/version Linux version 2.6.12.3 (root@chris) (gcc version 4.0.1) #1 Thu Jul 28 01:48:41 EDT 2005 root@chris:/usr/src# cfdisk -v cfdisk 2.12q Copyright (C) 1994-2002 Kevin E. Martin & aeb root@chris:/usr/src# cfdisk Segmentation fault
I discussed this on IRC a few days ago...one user confirmed it happened on his system as well (but he had multiple GCC4 systems - it worked fine on another system) and another said it worked fine for him.
comment:3 by , 19 years ago
I must admit I reported inaccurately. I am running updated versions of
udev linux kernel shadow
(perhaps others, but I'm not sure of what)
Sorry for the long list, but here is what I used before exiting chroot and rebooting:
-rw-r--r-- 1 rml users 1212701 Jul 28 12:56 autoconf-2.59.tar.gz -rw-r--r-- 1 rml users 984894 Jul 10 15:37 automake-1.9.6.tar.gz -rw-r--r-- 1 rml users 2418293 Jul 28 12:56 bash-3.0.tar.gz -rw-r--r-- 1 rml users 1994782 Aug 3 2004 bash-doc-3.0.tar.gz -rw-r--r-- 1 rml users 278926 Nov 15 2000 bc-1.06.tar.gz -rw-r--r-- 1 rml users 16378360 Jun 12 16:03 binutils-2.16.1.tar.gz -rw-r--r-- 1 rml users 1175541 Jul 28 12:56 bison-2.0.tar.gz -rw-r--r-- 1 rml users 669075 Jul 28 12:56 bzip2-1.0.3.tar.gz -rw-r--r-- 1 rml users 6623894 Jul 28 12:56 coreutils-5.2.1.tar.gz -rw-r--r-- 1 rml users 480439 Apr 11 21:15 cracklib-2.8.3.tar.gz -rw-r--r-- 1 rml users 4433906 Feb 4 2005 cracklib-words.gz -rw-r--r-- 1 rml users 1092317 Jul 28 12:56 dejagnu-1.4.4.tar.gz -rw-r--r-- 1 rml users 787375 Jul 28 12:56 diffutils-2.8.1.tar.gz -rw-r--r-- 1 rml users 3621193 Jul 1 16:46 e2fsprogs-1.38.tar.gz -rw-r--r-- 1 rml users 2623 Jul 28 12:56 etc_skel.tar.gz -rw-r--r-- 1 rml users 525570 Jul 28 12:56 expect-5.43.0.tar.gz -rw-r--r-- 1 rml users 549198 Aug 3 20:01 file-4.14.tar.gz -rw-r--r-- 1 rml users 978446 Jun 19 06:35 findutils-4.2.23.tar.gz -rw-r--r-- 1 rml users 861532 Jul 28 12:56 flex-2.5.31.tar.gz -rw-r--r-- 1 rml users 2274911 Jul 28 12:56 gawk-3.1.4.tar.gz -rw-r--r-- 1 rml users 20102104 Jul 7 20:34 gcc-core-4.0.1.tar.gz -rw-r--r-- 1 rml users 3784700 Jul 7 20:34 gcc-g++-4.0.1.tar.gz -rw-r--r-- 1 rml users 3981339 Jul 7 20:35 gcc-testsuite-4.0.1.tar.gz -rw-r--r-- 1 rml users 7105715 May 23 10:18 gettext-0.14.5.tar.gz -rw-r--r-- 1 rml users 18170636 Apr 7 00:55 glibc-2.3.5.tar.gz -rw-r--r-- 1 rml users 323684 Apr 7 00:55 glibc-linuxthreads-2.3.5.tar.gz -rw-r--r-- 1 rml users 667635 Aug 5 13:45 gpm-1.20.1.tar.gz -rw-r--r-- 1 rml users 634734 Jul 28 12:56 grep-2.5.1a.tar.gz -rw-r--r-- 1 rml users 2629169 Jul 28 12:56 groff-1.19.1.tar.gz -rw-r--r-- 1 rml users 971783 Aug 4 09:13 grub-0.97.tar.gz -rw-r--r-- 1 rml users 333256 Jul 28 12:56 gzip-1.3.5.tar.gz -rw-r--r-- 1 rml users 45334 Jul 28 12:56 hotplug-2004_09_23.tar.gz -rw-r--r-- 1 rml users 194479 Jul 4 06:57 iana-etc-1.10.tar.gz -rw-r--r-- 1 rml users 1047823 Jul 28 12:56 inetutils-1.4.2.tar.gz -rw-r--r-- 1 rml users 347051 Apr 1 13:59 iproute2-2.6.11-050330.tar.gz -rw-r--r-- 1 rml users 884840 Jul 28 12:56 kbd-1.12.tar.gz -rw-r--r-- 1 rml users 264427 Jul 28 12:56 less-382.tar.gz -rw-r--r-- 1 rml users 35457 May 2 02:24 lfs-bootscripts-3.2.1.tar.gz -rw-r--r-- 1 rml users 516693 Aug 5 20:39 libpng-1.2.8.tar.gz -rw-r--r-- 1 rml users 2780846 May 16 05:19 libtool-1.5.18.tar.gz -rw-r--r-- 1 rml users 46714222 Aug 5 16:11 linux-2.6.12.4.tar.gz -rw-r--r-- 1 rml users 3201024 Jul 6 12:02 linux-libc-headers-2.6.12.0.tar.gz -rw-r--r-- 1 rml users 2984347 Feb 4 2004 lynx-2.8.5.tar.gz -rw-r--r-- 1 rml users 383347 Mar 31 06:06 m4-1.4.3.tar.gz -rw-r--r-- 1 rml users 1219436 Jul 28 12:56 make-3.80.tar.gz -rw-r--r-- 1 rml users 234440 Jun 20 21:15 man-1.6.tar.gz -rw-r--r-- 1 rml users 2447616 Jul 19 03:37 man-pages-2.07.tar.gz -rw-r--r-- 1 rml users 70806 Jul 28 12:56 mktemp-1.5.tar.gz -rw-r--r-- 1 rml users 146544 Jul 28 12:56 module-init-tools-3.1.tar.gz -rw-r--r-- 1 rml users 49674 Nov 14 2004 module-init-tools-testsuite-3.1.tar.gz -rw-r--r-- 1 rml users 2154038 Jul 28 12:56 ncurses-5.4.tar.gz -rw-r--r-- 1 rml users 267571 Apr 15 2001 net-tools-1.60.tar.gz -rw-r--r-- 1 rml users 3132217 Apr 11 10:21 openssl-0.9.7g.tar.gz -rw-r--r-- 1 rml users 187675 Jul 28 12:56 patch-2.5.4.tar.gz -rw-r--r-- 1 rml users 817093 Aug 5 21:11 pcre-6.2.tar.gz -rw-r--r-- 1 rml users 12512211 May 30 17:19 perl-5.8.7.tar.gz -rw-r--r-- 1 rml users 968790 Jul 16 05:25 pkg-config-0.19.tar.gz -rw-r--r-- 1 rml users 277365 Jul 28 12:56 procps-3.2.5.tar.gz -rw-r--r-- 1 rml users 222454 Jul 28 12:56 psmisc-21.6.tar.gz -rw-r--r-- 1 rml users 1808946 Jul 28 12:56 readline-5.0.tar.gz -rw-r--r-- 1 rml users 794257 Jul 28 12:56 sed-4.1.4.tar.gz -rw-r--r-- 1 rml users 1651309 Aug 4 09:18 shadow-4.0.11.1.tar.gz -rw-r--r-- 1 rml users 796804 Aug 5 18:11 sharutils-4.4.tar.gz -rw-r--r-- 1 rml users 1304446 Aug 5 18:53 slang-2.0.4.tar.gz -rw-r--r-- 1 rml users 81784 Mar 11 2001 sysklogd-1.4.1.tar.gz -rw-r--r-- 1 rml users 99027 Jul 28 12:56 sysvinit-2.86.tar.gz -rw-r--r-- 1 rml users 2215311 Jul 28 12:56 tar-1.15.1.tar.gz -rw-r--r-- 1 rml users 3474428 Jun 29 12:18 tcl8.4.11-src.tar.gz -rw-r--r-- 1 rml users 2154292 Jul 28 12:56 texinfo-4.8.tar.gz -rw-r--r-- 1 rml users 542392 Aug 2 16:48 udev-065.tar.gz -rw-r--r-- 1 rml users 1140291 Feb 28 16:49 unzip-5.52.tar.gz -rw-r--r-- 1 rml users 2011862 Jul 28 12:56 util-linux-2.12q.tar.gz -rw-r--r-- 1 rml users 4543953 Jul 28 12:56 vim-6.3.tar.gz -rw-r--r-- 1 rml users 1593119 Jun 9 20:31 wget-1.10.tar.gz -rw-r--r-- 1 rml users 125696 Sep 14 2003 which-2.16.tar.gz -rw-r--r-- 1 rml users 781641 Mar 8 23:00 zip-2.31.tar.gz -rw-r--r-- 1 rml users 496597 Jul 18 08:38 zlib-1.2.3.tar.gz
comment:4 by , 19 years ago
Almost all of those are the exact same versions I have, except for a few packages that I don't have at all (autoconf, automake, libtool). The only difference is that I used a glibc snapshot (20050801) and linux-2.6.12.3. Maybe it's an really an issue with glibc, but I just asked WW981 on IRC what the glibc version was on his gcc4 system with the broken cfdisk and he said it was 2.3.5.
comment:5 by , 19 years ago
BTW what patches did you use, particularly for glibc? Just the ones in the book?
comment:6 by , 19 years ago
As best as I can remember, everything by-the-book. I had no issues building any package, only thing is that the inetutils patch is broken. It makes the FTP client segfault doing any operation.
comment:7 by , 19 years ago
I just built a new GCC4 system completely by-the-book in an attempt to see if the glibc-snapshot could have been the problem, but it doesn't make any difference. cfdisk still segfaults when I try to run it, though I did make some progress in determining where exactly the problem is. I noticed I can run "cfdisk -v" perfectly. Also, I can run "/sbin/cfdisk" as a nonprivileged user and it will start but complain about not being able to access the drive (since the user doesn't have permission to do that). I can also run "cfdisk -z" to have it start with a blank table instead of reading what's on the disk, and it works fine. But if I try to run "cfdisk -P t" it segfaults. Apparently the problem is in the code that reads the partition table from the disk, though I still don't know exactly what's causing it...
comment:8 by , 19 years ago
This is so odd. What type of disks are in your machine Chris, IDE, SATA, SCSI?
Here is my output:
root@rmlinux: /home/rml > cfdisk -P t Partition Table for /dev/hda
---Starting--- ----Ending---- Start Number of
# Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
1 0x80 1 1 0 0x83 254 63 1023 63 19551042 2 0x00 254 63 1023 0x83 254 63 1023 19551105 19567170 3 0x00 254 63 1023 0x82 254 63 1023 39118275 2923830 4 0x00 254 63 1023 0x05 254 63 1023 42042105 38363220 5 0x00 254 63 1023 0x83 254 63 1023 63 3903732 6 0x00 254 63 1023 0x83 254 63 1023 63 18603207 7 0x00 254 63 1023 0x83 254 63 1023 63 15856092
root@rmlinux: /home/rml > gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.0.1/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ Thread model: posix gcc version 4.0.1
comment:9 by , 19 years ago
root@chris:/home/chris# cfdisk -P t Segmentation fault root@chris:/home/chris# gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.0.1/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ Thread model: posix gcc version 4.0.1
My hard disk is IDE, if that helps... Also, just for fun, I tried seeing if fdisk and sfdisk had similar problems reading the partition table...nope, it's unique to cfdisk...
comment:10 by , 19 years ago
Got the same problem here but only on one system. It seems that it depends on the content of the partition table whether the bug gets exposed or not (maybe the existance of non-primary partitions?). It looks like it's a gcc 4 optimizer miscompilation, -funit-at-a-time is a problem candidate. Compiling cfdisk with -O instead of the default -O2 works around the problem here.
comment:11 by , 19 years ago
I can't reproduce this either, I'm afraid. Can someone report this upstream please? It might be worth doing the following:
- Compile util-linux with gcc-4.0.1 by the book.
- Grab a copy of gdb, run `gdb --args ./cfdisk -P t' 'run' (wait for it to segfault) 'bt' copy and paste the backtrace in the email.
- Compile util-linux with gcc-4.0.1 but use either '-O' or '-fno-unit-at-a-time'
- Run './cfdisk -P t' and copy and paste the (presumably successful) output
into the email.
comment:12 by , 19 years ago
Could someone see if 2.13-pre1 fixes this please? http://www.kernel.org/pub/linux/utils/util-linux/testing/util-linux-2.13-pre1.tar.bz2
I had a quick look at the diff between cfdisk.c but didn't see anything glaringly obvious that'd fix the segfault issue.
comment:13 by , 19 years ago
root@chris:/usr/src/util-linux-2.12q/fdisk# gdb --args ./cfdisk -P t GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run Starting program: /usr/src/util-linux-2.12q/fdisk/cfdisk -P t
Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? ()
I tried compiling cfdisk with optimizations, but util-linux apparently has a problem compiling anything with CFLAGS being set, and I couldn't figure out how to make it work. However, I noticed that util-linux 2.13-pre1 will work fine with CFLAGS (and yes, its cfdisk program has the same problem as the one in 2.12q) so I compiled that program with -O, and successfully ran it...
root@chris:/usr/src/util-linux-2.13-pre1/fdisk# ./cfdisk -P t Partition Table for /dev/hda
---Starting--- ----Ending---- Start Number of
# Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
1 0x80 1 1 0 0x07 254 63 1023 63 45592407 2 0x80 254 63 1023 0x83 254 63 1023 45592470 35150220 3 0x80 254 63 1023 0x83 254 63 1023 80742690 35150220 4 0x00 254 63 1023 0x83 254 63 1023 115892910 1317330
by , 19 years ago
Attachment: | util-linux-2.12q-fixes-1.patch added |
---|
fixes cfdisk with gcc4, and includes the cramfs patch
comment:14 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
With some help in IRC, I managed to get it work (with 2.12q). I had tried editing the Makefile for cfdisk and adding -O, but I just found out it only works if you put -O after $(CFLAGS) in the Makefile. The patch I just added here makes this modification to the Makefile for fdisk, and also includes the cramfs patch.
comment:15 by , 19 years ago
It works for some folks without the patch.
This is the part that puzzles me, why it works for some, and not for others. I know I don't need a patch, and installing something I don't need, is not something I typically would do.
comment:16 by , 19 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
Please don't mark bugs as fixed. This hasn't been addressed in the book yet, therefore can't be closed. As it is, I'm not happy with the patch. This just works around the issue. I'd prefer it if you could report the problem upstream after getting some debug output. I believe, if you remove the change the '-O2' parameter in MCONFIG:141 to '-g' you should get reasonable results from gdb.
comment:17 by , 19 years ago
Oops, sorry. I tried adding -g to the Makefile but it doesn't change anything. What do you mean by "MCONFIG: 141"? (shows how qualified I am to mess with this stuff...)
comment:18 by , 19 years ago
There's a file called MCONFIG in the util-linux-2.12q directory. Change line 141 of that file so that '-O2' isn't there any longer and '-g' is. Hmmm, having said that, removing the -O2 will make the problem go away. OK, try changing the '-O2' to '-funit-at-a-time' (as that's one of the suspect flags) and then adding '-g' to the same line. http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Optimize-Options.html#Optimize-Options shows all of the flags that are turned on by '-02', so if '-O' or '-O1' works fine then it'll be one or a combination of those that are causing the problem!
comment:19 by , 19 years ago
AFAICT it depends on the used partition table, so it seems that there is no system where it works without a patch for a given problematic partition table.
comment:20 by , 19 years ago
Chris, please ignore my previous comment. Change line 62 of 'configure' to remove the '-s' flag from LDFLAGS. That should prevent the binaries from getting stripped and therefore gdb should be much more useful.
Thanks,
Matt.
comment:21 by , 19 years ago
Thanks, that explains why I kept getting the same output from gdb every time. :)
comment:23 by , 19 years ago
With Matt's help I managed to get the program to compile with debugging info (but otherwise built by-the-book) and ran it through gdb step by step. Here's the last part of the debugging output - http://pastebin.linuxfromscratch.org/?show=1328
comment:24 by , 19 years ago
I still can't reproduce this. Here's what `cfdisk -P t' gives me:
---Starting--- ----Ending---- Start Number of
# Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
1 0x80 1 1 0 0x83 254 63 2 63 48132 2 0x00 0 1 3 0x83 254 63 1023 48195 38572065 3 0x00 254 63 1023 0x83 254 63 1023 38620260 38572065 4 0x00 254 63 1023 0x82 254 63 1023 77192325 979965
comment:25 by , 19 years ago
I'm seeing this bug. cfdisk compiled with gcc-4.0.1 segfaults. I recompiled it with optimisation set to -O and now it runs fine.
root:/home/andy# cfdisk -P t Partition Table for /dev/hda
---Starting--- ----Ending---- Start Number of
# Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------
1 0x80 1 1 0 0x07 254 63 1023 63 19534977 2 0x00 254 63 1023 0x83 254 63 1023 19535040 9767520 3 0x00 254 63 1023 0x83 254 63 1023 29302560 9767520 4 0x00 254 63 1023 0x05 254 63 1023 39070080 148456665 5 0x00 254 63 1023 0x82 254 63 1023 63 1959867 6 0x00 254 63 1023 0x83 254 63 1023 63 97659072 7 0x00 254 63 1023 0x83 254 63 1023 63 9767457 8 0x80 254 63 1023 0x83 254 63 1023 63 9767457 9 0x00 254 63 1023 0x83 254 63 1023 63 9767457
10 0x00 254 63 1023 0x83 254 63 1023 63 9767457 11 0x00 254 63 1023 0x83 254 63 1023 63 9767457 root:/home/andy#
If I reboot into hda2 (also compiled with gcc-4) it still segfaults as I've not fixed that one. I fixed the CFLAGS with this sed because I was unaware of the patch
sed -i 's@CFLAGS-"-O2"@CFLAGS-"-O"@g' configure
comment:26 by , 19 years ago
The partition tables in comment 13 and comment 26 both show an NTFS partition as the first partition. Thinking it may just be the presence of an NTFS partition anywhere on the disk that causes the bug, I created one over my swap partition.
Alas, cfdisk still runs for me. So it looks like the error case is having an
NTFS partition as the first one on a disk. Are either of you (Chris and Andrew) in a position where you can change the type of those NTFS partitions?
Cheers,
Matt.
comment:27 by , 19 years ago
(In reply to comment #27)
Are either of you (Chris and Andrew) in a position where you can change the type of those NTFS partitions?
Cheers,
Matt.
That was one of the first things I did. I removed the hda1 partition, recompiled util-linux, and it still segfault. I readded the partition (now just a "linux" partition) and it segfaulted again. Then I tried various other combinations...here's the results...
hda2 stays because it's the one I'm using at the moment :)
blank space, hda2, blank, hda4 - segfault blank space, hda2, hda3, hda4 - segfault hda1, hda2, hda3 - segfault hda1, hda2, hda3, blank space - segfault blank space, hda2, hda3, blank space - works blank space, hda2, hda3 - works blank space, hda2, blank space - works
Good luck finding a pattern in all of this...
comment:28 by , 19 years ago
Owner: | changed from | to
---|
comment:29 by , 19 years ago
Status: | new → assigned |
---|
comment:30 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I can display different behavior. Behavior normal and expected:
root@rmlinux: /home/randy > gcc --version gcc (GCC) 4.0.1 Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@rmlinux: /home/randy > cfdisk
root@rmlinux: /home/randy >
Of course, this doesn't show that cfdisk worked just perfectly for me to display the existing partition table, and I did not try to create a new partition using it. However, it appears normal to me. I'm using branch GCC4-050730