gcc-4.4 4.4.2-1ubuntu2/3 __builtin_offsetof and & (address of) seems to trigger "internal compiler error: Segmentation fault"

Bug #475450 reported by Andy Whitcroft
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.4 (Ubuntu)
Fix Released
High
Matthias Klose

Bug Description

Binary package hint: gcc-4.4

I am getting failures when trying to build the Lucid kernel with the gcc-4.4
4.4.2-1ubuntu2 compiler. It seems to throw internal errors and core dump on
some incantations of offsetof/container_of, but it does not appear all:

    ipc/util.c: In function 'ipc_schedule_free':
    ipc/util.c:572: internal compiler error: Segmentation fault

        static void ipc_schedule_free(struct rcu_head *head)
        {
                struct ipc_rcu_grace *grace;
                struct ipc_rcu_sched *sched;

                grace = container_of(head, struct ipc_rcu_grace, rcu);
     -> sched = container_of(&(grace->data[0]), struct ipc_rcu_sched,
                                        data[0]);

                INIT_WORK(&sched->work, ipc_do_vfree);
                schedule_work(&sched->work);
        }

    ext4/mballoc.c: In function 'ext4_mb_add_groupinfo':
    ext4/mballoc.c:2230: internal compiler error: Segmentation fault

        /*
         * calculate needed size. if change bb_counters size,
         * don't forget about ext4_mb_generate_buddy()
         */
     -> len = offsetof(typeof(**meta_group_info),
                       bb_counters[sb->s_blocksize_bits + 2]);

    kernel/audit_tree.c: In function 'find_chunk':
    kernel/audit_tree.c:206: internal compiler error: Segmentation fault

        static struct audit_chunk *find_chunk(struct node *p)
        {
                int index = p->index & ~(1U<<31);
                p -= index;
     -> return container_of(p, struct audit_chunk, owners[0]);
        }

Andy Whitcroft (apw)
Changed in gcc-4.4 (Ubuntu):
importance: Undecided → High
Revision history for this message
Andy Whitcroft (apw) wrote : Re: gcc-4.4 4.4.2-1ubuntu2 offfsetof seems to trigger "internal compiler error: Segmentation fault"

Note that container_of() is defined thus:

    #define container_of(ptr, type, member) ({ \
        const typeof( ((type *)0)->member ) *__mptr = (ptr); \
        (type *)( (char *)__mptr - offsetof(type,member) );})

summary: - gcc-4.4 4.4.2-1ubuntu2 offfsetof/container_of seems to trigger "internal
- compiler error: Segmentation fault"
+ gcc-4.4 4.4.2-1ubuntu2 offfsetof seems to trigger "internal compiler
+ error: Segmentation fault"
Revision history for this message
Andy Whitcroft (apw) wrote :

Ok I have managed to reduce this to a sensible reproduce by as below:

$ cat X.c
struct foo {
        unsigned long foo_A;
        int foo_B[];
};

void bar()
{
        __builtin_offsetof(typeof(struct foo), foo_B[2]);
}

$ gcc-4.4 -c X.c
X.c: In function 'bar':
X.c:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.

summary: - gcc-4.4 4.4.2-1ubuntu2 offfsetof seems to trigger "internal compiler
- error: Segmentation fault"
+ gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof seems to trigger "internal
+ compiler error: Segmentation fault"
Revision history for this message
Andy Whitcroft (apw) wrote : Re: gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof seems to trigger "internal compiler error: Segmentation fault"

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.2-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.2 (Ubuntu 4.4.2-1ubuntu2)

Revision history for this message
Andy Whitcroft (apw) wrote :
Download full text (4.2 KiB)

$ cc -E -dM -xc /dev/null
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 2147483647
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __FLT_EVAL_METHOD__ 0
#define __unix__ 1
#define __x86_64 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 2
#define __DEC64_MAX_EXP__ 385
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINTMAX_TYPE__ long unsigned int
#define __linux 1
#define __DEC32_EPSILON__ 1E-6DF
#define __unix 1
#define __LDBL_MAX_EXP__ 16384
#define __linux__ 1
#define __SCHAR_MAX__ 127
#define __DBL_DIG__ 15
#define _FORTIFY_SOURCE 2
#define __SIZEOF_INT__ 4
#define __SIZEOF_POINTER__ 8
#define __USER_LABEL_PREFIX__
#define __STDC_HOSTED__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __FLT_EPSILON__ 1.19209290e-7F
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
#define __DEC32_MAX__ 9.999999E96DF
#define __SIZEOF_LONG__ 8
#define __DECIMAL_DIG__ 21
#define __gnu_linux__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 4
#define __MMX__ 1
#define __FLT_HAS_DENORM__ 1
#define __SIZEOF_LONG_DOUBLE__ 16
#define __BIGGEST_ALIGNMENT__ 16
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_HAS_INFINITY__ 1
#define __DEC32_MIN_EXP__ (-94)
#define __LDBL_HAS_DENORM__ 1
#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
#define __DEC32_MIN__ 1E-95DF
#define __DBL_MAX_EXP__ 1024
#define __DEC128_EPSILON__ 1E-33DL
#define __SSE2_MATH__ 1
#define __amd64 1
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __SIZEOF_SIZE_T__ 8
#define __SIZEOF_WINT_T__ 4
#define __GCC_HAVE_DWARF2_CFI_ASM 1
#define __GXX_ABI_VERSION 1002
#define __FLT_MIN_EXP__ (-125)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __LP64__ 1
#define __DECIMAL_BID_FORMAT__ 1
#define __DEC128_MIN__ 1E-6143DL
#define __REGISTER_PREFIX__
#define __DBL_HAS_DENORM__ 1
#define __NO_INLINE__ 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "4.4.2"
#define __DEC64_EPSILON__ 1E-15DD
#define __DEC128_MIN_EXP__ (-6142)
#define unix 1
#define __SIZE_TYPE__ long unsigned int
#define __ELF__ 1
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
#define __SSE_MATH__ 1
#define __k8 1
#define __SIZEOF_PTRDIFF_T__ 8
#define __x86_64__ 1
#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 9223372036854775807L
#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
#define __FLT_HAS_INFINITY__ 1
#define __DEC64_MAX__ 9.999999999999999E384DD
#define __CHAR16_TYPE__ short unsigned int
#define __DEC64_MANT_DIG__ 16
#define __DEC32_MAX_EXP__ 97
#define linux 1
#define __SSE2__ 1
#define __LDBL_MANT_DIG__ 64
#define __DBL_HAS_QUIET_NAN__ 1
#define __k8__ 1
#define __WCHAR_TYPE__ int
#define __SIZEOF_FLOAT__ 4
#define __DEC64_MIN_EXP__ (-382)
#define __FLT_DIG__ 6
#define __INT_MAX__ 2147483647
#define __amd64__ 1
#d...

Read more...

Revision history for this message
Andy Whitcroft (apw) wrote :

I have also found another crash in the & operator, the following code triggers another crash:

struct foo {
 unsigned short foo_A;
 struct {
  unsigned int foo_B;
 } foo_C[];
};

void bar()
{
  &((struct foo *)0)->foo_C[2].foo_B;
}

summary: - gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof seems to trigger "internal
- compiler error: Segmentation fault"
+ gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof and & (address of) seems to
+ trigger "internal compiler error: Segmentation fault"
Revision history for this message
Andy Whitcroft (apw) wrote : Re: gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof and & (address of) seems to trigger "internal compiler error: Segmentation fault"

Talking to doko he suggested trying these same fragments on the 4.4.2-1ubuntu1. Both compile without incident there.

I am told that these two uploads represent these SVN commits:

    4.4.2-1ubuntu2 is r153898
    4.4.2-1ubuntu1 is r153603

Revision history for this message
Andy Whitcroft (apw) wrote :

As these compile without incident on the official snapshot of 4.4.2 upstream is not interested in the bugs according to their acceptance criteria. I have therefore not reported them upstream.

Revision history for this message
Andy Whitcroft (apw) wrote :

I have also been unable to exclude all of the instances of these operators from the kernel.

Changed in gcc-4.4 (Ubuntu):
assignee: nobody → Matthias Klose (doko)
summary: - gcc-4.4 4.4.2-1ubuntu2 __builtin_offsetof and & (address of) seems to
+ gcc-4.4 4.4.2-1ubuntu2/3 __builtin_offsetof and & (address of) seems to
trigger "internal compiler error: Segmentation fault"
Revision history for this message
Matthias Klose (doko) wrote :

fixed in lucid

Changed in gcc-4.4 (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.