Bug 211084 - Segmentation fault in main
Segmentation fault in main
Status: CLOSED NEXTRELEASE
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: setuptool (Show other bugs)
4.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Nalin Dahyabhai
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-17 05:10 EDT by Dominic Scheirlinck
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-10-18 11:51:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
test update (159.82 KB, application/x-redhat-package-manager)
2006-10-17 11:03 EDT, Nalin Dahyabhai
no flags Details
strace log (12.63 KB, text/plain)
2006-10-18 10:46 EDT, Dominic Scheirlinck
no flags Details

  None (edit)
Description Dominic Scheirlinck 2006-10-17 05:10:54 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1) Gecko/20061003 Firefox/2.0

Description of problem:
Binary RPM of setuptool gives undescriptive segmentation fault. Source package gives same segmentation fault when compiled, did so with debug symbols to give:

Starting program: /usr/src/redhat/SOURCES/setuptool-1.17/setup
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xbfffe000

Program received signal SIGSEGV, Segmentation fault.
0x08049113 in main (argc=1, argv=0xbffe5f34) at setup.c:167
167                  strcmp(tools[i].name, tools[i + 1].name) == 0) {

At the point the segmentation fault occurs, it looks like tools is null:

(gdb) print tools
$1 = (struct tool *) 0x0



Version-Release number of selected component (if applicable):
setuptool-1.17

How reproducible:
Always


Steps to Reproduce:
1. Grab and install source RPM
2. ./configure --enable-debug
3. make

Compile proceeds with no errors.

Actual Results:


Expected Results:


Additional info:
Comment 1 Nalin Dahyabhai 2006-10-17 08:42:51 EDT
This looks like it happens if $sysconfdir/setuptool.d is empty or doesn't
contain anything recognizable as a setuptool configuration file ($sysconfdir
defaults to /etc in the binaries).  Can you double-check that your system is not
missing some or all of these files?  (The particular bug should be fixed in
1.19, but I'm trying to figure out how you came across it.)
Comment 2 Dominic Scheirlinck 2006-10-17 08:55:28 EDT
Contents of /etc/setuptool.d/:

-rw-r--r--  1 root root 42 Mar  2  2005 98netconfig
-rw-r--r--  1 root root 47 Mar  2  2005 98system-config-display
-rw-r--r--  1 root root 62 Mar  2  2005 98system-config-keyboard
-rw-r--r--  1 root root 40 Mar  2  2005 99Xconfigurator
-rw-r--r--  1 root root 50 Mar  2  2005 99authconfig
-rw-r--r--  1 root root 43 Mar  2  2005 99kbdconfig
-rw-r--r--  1 root root 40 Mar  2  2005 99lokkit
-rw-r--r--  1 root root 42 Mar  2  2005 99mouseconfig
-rw-r--r--  1 root root 33 Mar  2  2005 99ntsysv
-rw-r--r--  1 root root 46 Mar  2  2005 99printconf-tui
-rw-r--r--  1 root root 45 Mar  2  2005 99sndconfig
-rw-r--r--  1 root root 58 Mar  2  2005 99system-config-network-tui
-rw-r--r--  1 root root 58 Mar  2  2005 99system-config-printer-tui
-rw-r--r--  1 root root 44 Mar  2  2005 99timeconfig

They all seem to be there - contents seem to be pretty normal. Copying across
the setuptool.d directory from the source RPM (with a chown to root) doesn't
seem to help either.
Comment 3 Nalin Dahyabhai 2006-10-17 09:05:37 EDT
Keep in mind that 'configure' sets the default value of $sysconfdir to
/usr/local/etc unless it's overridden (when invoked from 'rpmbuild -bc'
, it's passed '--sysconfdir=/etc'), so I'm not certain that you're
hitting the same problem in both cases.
Comment 4 Dominic Scheirlinck 2006-10-17 09:31:08 EDT
Ah, you're quite right. Invoking configure from rpmbuild -bc still gives a
segfault, but it's happening in a different place:

Program received signal SIGSEGV, Segmentation fault.
0x08049539 in main (argc=1, argv=0xbf8c1a14) at setup.c:98
98                        if (strlen(p) == 0) {
(gdb) print p
$1 = 0xbf8c1140 ""
Comment 5 Dominic Scheirlinck 2006-10-17 09:32:58 EDT
Although this still looks like something to do with the configuration directory...
Comment 6 Nalin Dahyabhai 2006-10-17 09:41:39 EDT
Can you run 'cat /etc/setuptool.d/*' and add the result here?  Either
strtok() is behaving strangely, or one of the configuration files has
bad data in it, and neither of those should be happening.  (Though this
is another bug that needs to be fixed for 1.19.)
Comment 7 Dominic Scheirlinck 2006-10-17 09:44:13 EDT
[root@milwaukeemicrobusiness setuptool.d]# cat /etc/setuptool.d/*
/usr/sbin/netconfig|Network configuration
/usr/bin/system-config-display|X configuration
/usr/bin/system-config-keyboard --text|Keyboard configuration
/usr/sbin/Xconfigurator|X configuration
/usr/sbin/authconfig|Authentication configuration
/usr/sbin/kbdconfig|Keyboard configuration
/usr/sbin/lokkit|Firewall configuration
/usr/sbin/mouseconfig|Mouse configuration
/usr/sbin/ntsysv|System services
/usr/sbin/printconf-tui|Printer configuration
/usr/sbin/sndconfig|Sound card configuration
/usr/sbin/system-config-network-tui|Network configuration
/usr/sbin/system-config-printer-tui|Printer configuration
/usr/sbin/timeconfig|Timezone configuration
Comment 8 Nalin Dahyabhai 2006-10-17 11:02:37 EDT
Okay, this doesn't make much sense to me -- those all look like correct
configuration files, and in each case strtok() should be returning the
first part of each line.
Comment 9 Nalin Dahyabhai 2006-10-17 11:03:58 EDT
Created attachment 138686 [details]
test update

Can you try rebuilding the attached source package?  It should fix both of
the problems we've seen here.
Comment 10 Dominic Scheirlinck 2006-10-17 17:48:39 EDT
Here's the build process:

[root@milwaukeemicrobusiness redhat]# rpm -i /root/setuptool-1.17-3.src.rpm
warning: user brewbuilder does not exist - using root
warning: group brewbuilder does not exist - using root
warning: user brewbuilder does not exist - using root
warning: group brewbuilder does not exist - using root
warning: user brewbuilder does not exist - using root
warning: group brewbuilder does not exist - using root

[root@milwaukeemicrobusiness redhat]# rpmbuild -bc SPECS/setuptool.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.50028
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd /usr/src/redhat/BUILD
+ rm -rf setuptool-1.17
+ /bin/gzip -dc /usr/src/redhat/SOURCES/setuptool-1.17.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd setuptool-1.17
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chown -Rhf root .
++ /usr/bin/id -u
+ '[' 0 = 0 ']'
+ /bin/chgrp -Rhf root .
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (setuptool-backports.patch):'
Patch #0 (setuptool-backports.patch):
+ patch -p0 -b --suffix .backports -s
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.50028
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd setuptool-1.17
+ CFLAGS='-O2 -g -march=i386 -mcpu=i686'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -march=i386 -mcpu=i686'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -march=i386 -mcpu=i686'
+ export FFLAGS
+ ./configure --host=i686-redhat-linux-gnu --build=i686-redhat-linux-gnu
--target=i386-redhat-linux --program-prefix= --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share
--includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec
--localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for i686-redhat-linux-gnu-gcc... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for LC_MESSAGES... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking for dgettext in libc... yes
checking for bind_textdomain_codeset... yes
checking for msgfmt... /usr/bin/msgfmt
checking for dcgettext... yes
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for catalogs to be installed...  ar be bg bn bs ca cs cy da de el es et
fi fr gu he hi hr hu id is it ja ka ko ku lo lt mk mn mr ms nb nl no pa pl pt
pt_BR ru si sk sl sq sv ta tr uk ur vi zh_CN zh_TW
checking for perl... /usr/bin/perl
checking for XML::Parser... ok
configure: creating ./config.status
config.status: creating Makefile
config.status: creating setuptool.d/Makefile
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default-1 commands
config.status: executing default-2 commands
+ make
make  all-recursive
make[1]: Entering directory `/usr/src/redhat/BUILD/setuptool-1.17'
Making all in po
make[2]: Entering directory `/usr/src/redhat/BUILD/setuptool-1.17/po'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/src/redhat/BUILD/setuptool-1.17/po'
Making all in setuptool.d
make[2]: Entering directory `/usr/src/redhat/BUILD/setuptool-1.17/setuptool.d'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/src/redhat/BUILD/setuptool-1.17/setuptool.d'
make[2]: Entering directory `/usr/src/redhat/BUILD/setuptool-1.17'
if gcc -DHAVE_CONFIG_H -DGETTEXT_PACKAGE=\"setup\"
-DSETUPTOOLDDIR=\"/etc/setuptool.d\" -I. -I. -I.     -O2 -g -march=i386
-mcpu=i686 -MT setup.o -MD -MP -MF ".deps/setup.Tpo" -c -o setup.o setup.c; \
then mv -f ".deps/setup.Tpo" ".deps/setup.Po"; else rm -f ".deps/setup.Tpo";
exit 1; fi
gcc  -O2 -g -march=i386 -mcpu=i686   -o setup  setup.o -lnewt
make[2]: Leaving directory `/usr/src/redhat/BUILD/setuptool-1.17'
make[1]: Leaving directory `/usr/src/redhat/BUILD/setuptool-1.17'
+ exit 0

---
And here's what happens next:

[root@milwaukeemicrobusiness redhat]# BUILD/setuptool-1.17/setup

ERROR - No tool descriptions found in /etc/setuptool.d.

---
But:

[root@milwaukeemicrobusiness redhat]# ls /etc/setuptool.d/
98netconfig               99kbdconfig      99sndconfig
98system-config-display   99lokkit         99system-config-network-tui
98system-config-keyboard  99mouseconfig    99system-config-printer-tui
99Xconfigurator           99ntsysv         99timeconfig
99authconfig              99printconf-tui
[root@milwaukeemicrobusiness redhat]# diff /etc/setuptool.d/
BUILD/setuptool-1.17/setuptool.d
Only in BUILD/setuptool-1.17/setuptool.d: Makefile
Only in BUILD/setuptool-1.17/setuptool.d: Makefile.am
Only in BUILD/setuptool-1.17/setuptool.d: Makefile.in
Comment 11 Nalin Dahyabhai 2006-10-18 10:03:32 EDT
This gets weirder and weirder.  Can you run
"strace -s256 -o /tmp/setup.log setup" and attach
the generated log?  I'm wondering if the tool is
running into some permissions problem, and the log
should turn up some clues.
Comment 12 Dominic Scheirlinck 2006-10-18 10:46:05 EDT
Created attachment 138790 [details]
strace log

It looks like it's still using /usr/local/etc/ as the sysconfdir (this binary
was created with rpmbuild -bc). To double check, I did a manual build with
'./configure --sysconfdir=/etc' - same result.
Comment 13 Dominic Scheirlinck 2006-10-18 10:51:24 EDT
Actually, /usr/local/etc/ does exist, and seems to work fine. Turns out the
segmentation fault occurs because none of the tools are available under
/usr/sbin/ - installing any one of them, like, say, authconfig - stops the segfault.
Comment 14 Nalin Dahyabhai 2006-10-18 10:58:57 EDT
Okay, so the tool builds the list of options to present in thelistbox,
and if it found nothing, it would crash.  The additional check for not
having any valid options to present is now causing the error message
to be produced instead, so I think we're okay there.

But this /usr/local/etc thing, that's still unexplained.  The code as
written scans SETUPTOOLDDIR, which I can see from your build log is
getting the right value.  Unless the strace log was generated using a
different binary, I'm not really sure how it could have ended up
scanning the wrong directory.
Comment 15 Dominic Scheirlinck 2006-10-18 11:06:36 EDT
Yep, that's exactly what happened in that strace. I did 'strace -s256 -o
/tmp/setup.log setup' not 'strace -s256 -o /tmp/setup.log ./setup'

The correct log is working fine:
open("/etc/setuptool.d/99system-config-printer-tui", O_RDONLY) = 4

So, I think that's everything.
Comment 16 Nalin Dahyabhai 2006-10-18 11:51:13 EDT
Excellent!

I don't think this is a bug you'd run into normally, because
authconfig is a required part of the base package set.  Given
that, I'm just going to mark this as fixed in the next release.

Note You need to log in before you can comment on or make changes to this bug.