Bug 433787

Summary: gcc inline bug causes dumpe2fs segfault in ia64
Product: Red Hat Enterprise Linux 4 Reporter: Flavio Leitner <fleitner>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 4.6CC: esandeen
Target Milestone: rc   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-02-21 18:11:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Flavio Leitner 2008-02-21 14:13:06 UTC
Description of problem:
# /sbin/dumpe2fs -f -h /dev/mapper/myvg-rootvol > /dev/null
dumpe2fs 1.35 (28-Feb-2004)
Segmentation fault

backtrace:
#0  ext2fs_u32_list_iterate_begin (bb=0x0, ret=0x60000fffffffb2f8) at
badblocks.c:242
242             EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST);

(gdb) bt
#0  ext2fs_u32_list_iterate_begin (bb=0x0, ret=0x60000fffffffb2f8) at
badblocks.c:242
#1  0x20000000000556c0 in ext2fs_badblocks_list_iterate_begin (bb=0x0,
ret=0x60000fffffffb2f8) at badblocks.c:258

#2  0x4000000000001930 in list_bad_blocks (fs=0x6000000000009000, dump=0) at
dumpe2fs.c:195

#3  0x4000000000002240 in main (argc=4, argv=0x60000fffffffba18) at dumpe2fs.c:353

#4  0x20000000000fd430 in __libc_start_main () from /lib/tls/libc.so.6.1
#5  0x4000000000001440 in _start ()

The macro is expanded to:
#define EXT2_CHECK_MAGIC(struct, code) \
        if ((struct)->magic != (code)) return (code)

and the variable 'struct' in this case is a NULL pointer.

Compiling with:
# CFLAGS="-O2  -fno-inline" ./configure --enable-elf-shlibs --enable-nls

does not reproduce anymore:
[root@rx1620 e2fsprogs-1.35]# LD_PRELOAD=lib/libext2fs.so.2 misc/dumpe2fs -f -h
/dev/mapper/myvg-rootvol > /dev/null
dumpe2fs 1.35 (28-Feb-2004)
#

Version-Release number of selected component (if applicable):
gcc-3.4.6-9
e2fsprogs-1.35-12.11.el4_6.1

How reproducible:
Always

Steps to Reproduce:
1. Compile using CFLAGS="-O2" 
2. Run dumpe2fs command as described above
3. segfault

Additional info:
It's a known problem on ARM too, check the report below:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=397044

Flavio

Comment 1 Jakub Jelinek 2008-02-21 14:27:29 UTC
If you read the debian bug carefully, you'll find it wasn't a gcc bug, but
e2fsprogs aliasing violation.
Try to build with CFLAGS="-O2 -fno-strict-aliasing", if that helps, find out
which exact function is miscompiled with -O2 (with default -fstrict-aliasing)
and post here preprocessed source of the CU containing that function, I guess I
can then show you the aliasing violation (if there is any).

Comment 2 RHEL Program Management 2008-02-21 14:27:51 UTC
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".

Comment 3 RHEL Program Management 2008-02-21 14:48:06 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 4 Flavio Leitner 2008-02-21 18:11:25 UTC
Yes, building with CFLAGS="-O2 -fno-strict-aliasing" does indeed fix the problem.
I've missed the cloned ticket at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=398316

e2fsprogs ticket is bz#433784 then I'm closing this one.
thanks much!
Flavio