Bug 26968 - [4.1 Regression] HDF5 1.7.52 test segfaults with 4.1.0, fine with 4.0.2 (regression)
Summary: [4.1 Regression] HDF5 1.7.52 test segfaults with 4.1.0, fine with 4.0.2 (regr...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-31 23:07 UTC by Orion Poplawski
Modified: 2006-12-09 22:40 UTC (History)
2 users (show)

See Also:
Host: i386-redhat-linux
Target: i386-pc-linux-gnu
Build:
Known to work: 4.2.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orion Poplawski 2006-03-31 23:07:28 UTC
Still trying to get more info, but here is what I have.

Trying to build HDF5 1.7.52 on Fedora Core 5 i386 with gcc-4.1.0-3 (also seem to see it with gcc-4.1.0-4 from rawhide).

The Dataspaces (h5s) test segfaults.

I've tracked it down to the following code in H5Dio.c:2263-2270 (in H5D_create_chunk_map) apparently not actually setting fm->chunk_dim:

    /* Decide the number of chunks in each dimension*/
    for(u=0; u<f_ndims; u++) {
        /* Keep the size of the chunk dimensions as hsize_t for various routines */
        fm->chunk_dim[u]=fm->layout->u.chunk.dim[u];

        /* Round up to the next integer # of chunks, to accomodate partial chunks */
        fm->chunks[u] = ((fm->f_dims[u]+dataset->shared->layout.u.chunk.dim[u])-1) / dataset->shared->layout.u.chunk.dim[u];
    } /* end for */

Probably is getting optimized away for some reason.  fm->chunk_dim is not reference again in H5D_create_chunk_map, but it is later on 

I have not been able to distill to a simple test case.

Flags used to compile are the standard RPM_OPT_FLAGS for FC5:

-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables

Flags used with 4.0.2 were:

-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=penti
um4 -fasynchronous-unwind-tables

So there might be something there too....
Comment 1 Andrew Pinski 2006-03-31 23:14:26 UTC
Can you try first without -fstack-protector.  If that does not work, try with -fno-strict-aliasing added to see if maybe there is an aliasing issue.
Comment 2 Orion Poplawski 2006-03-31 23:32:40 UTC
Compiled using 4.1.0 with the old 4.0.2 (FC4) flags (no -fstack-protector and --param=ssp-buffer-size=4) with no effect.

Added -fno-strict-aliasing with no effect (at least for this, I've got a type conversion issue to track down next...).

Comment 3 Orion Poplawski 2006-03-31 23:34:56 UTC
Sorry, my browser seems to have changed components...
Comment 4 Richard Biener 2006-04-01 15:42:35 UTC
Note that you definitely need -fno-strict-aliasing from looking at hdf5 the last time.
Comment 5 Andrew Pinski 2006-04-02 08:26:20 UTC
We need a self contained testcase here.
Can you read http://gcc.gnu.org/bugs.html and attach the preprocessed source as requested?
Comment 6 Orion Poplawski 2006-04-03 16:24:24 UTC
Hmm, tried adding -save-temps to my flags so that I could collect .s and .i files, but it appears that the segfault also goes away.  Removing -save-temps indeed goes back to the previous behavior.  Removing -pipe has no effect.  Perhaps this isn't a 4.0.2 -> 4.1.0 thing as much as a FC4->FC5 things.  I'll try using 4.1.0 on FC4 and 4.0.2 on FC5 if possible.
Comment 7 Orion Poplawski 2006-04-03 21:13:00 UTC
Looks like adding -save-temps to the flags breaks the configure check for -fPIC, so the code be built with -save-temps that worked also did not have -fPIC (perhaps that is a clue).  Trick was to remove -pipe when using -save-temps to avoid a gcc warning that was confusing configure, now I can get .i and .s from the failed 4.1.0 compile.

Just is case there is something obvious, here are asm snippets of the loop in question from

4.0.2:
        .loc 1 2264 0
        movl    -2068(%ebp), %ecx       #,
        testl   %ecx, %ecx      #
        je      .L201   #,
        movl    12(%ebp), %esi  # fm, ivtmp.708
        xorl    %edi, %edi      # u.1013
.LVL48:
        movl    3052(%esi), %edx        # <variable>.layout,
        movl    %edx, -2088(%ebp)       #,
.L200:
        .loc 1 2266 0
        movl    -2088(%ebp), %edx       #,
        movl    20(%edx,%edi,4), %edx   # <variable>.u.chunk.dim,
        movl    %edx, 2524(%esi)        #, <variable>.chunk_dim
        movl    $0, 2528(%esi)  #, <variable>.chunk_dim
        .loc 1 2269 0
        movl    -2028(%ebp), %ecx       # dataset,
        movl    52(%ecx), %eax  # <variable>.shared, <variable>.shared
        movl    84(%eax,%edi,4), %edx   # <variable>.layout.u.chunk.dim,
        xorl    %ecx, %ecx      #
        movl    %edx, -2024(%ebp)       #, D.12413
        movl    %ecx, -2020(%ebp)       #, D.12413
        addl    28(%esi), %edx  # <variable>.f_dims,
        adcl    32(%esi), %ecx  # <variable>.f_dims,
        movl    %edx, -2112(%ebp)       #,
        movl    %ecx, -2108(%ebp)       #,
        addl    $-1, -2112(%ebp)        #,
        adcl    $-1, -2108(%ebp)        #,
        movl    -2024(%ebp), %eax       # D.12413,
        movl    -2020(%ebp), %edx       # D.12413,
        movl    %eax, 8(%esp)   #,
        movl    %edx, 12(%esp)  #,
        movl    -2112(%ebp), %edx       #,
        movl    -2108(%ebp), %ecx       #,
        movl    %edx, (%esp)    #,
        movl    %ecx, 4(%esp)   #,
        call    __udivdi3@PLT   #
        movl    %eax, 2260(%esi)        # tmp302, <variable>.chunks
        movl    %edx, 2264(%esi)        #, <variable>.chunks
        .loc 1 2264 0
        addl    $1, %edi        #, u.1013
        addl    $8, %esi        #, ivtmp.708
        cmpl    %edi, -1996(%ebp)       # u.1013, f_ndims
        jne     .L200   #,
.L201:
        .loc 1 2273 0

4.1.0:
        .loc 1 2264 0
        movl    -1952(%ebp), %edx       # f_ndims,
        testl   %edx, %edx      #
        je      .L241   #,
        .loc 1 2260 0
        movl    $0, -1948(%ebp) #, u
.LVL83:
        movl    12(%ebp), %eax  # fm,
        movl    3052(%eax), %eax        # <variable>.layout,
        movl    %eax, -2008(%ebp)       #,
.L246:
        .loc 1 2266 0
        movl    -1948(%ebp), %edx       # u,
        movl    12(%ebp), %ecx  # fm,
        movl    20(%ecx,%edx,4), %esi   # <variable>.u.chunk.dim,
        movl    %esi, 2524(%ecx,%edx,8) #, <variable>.chunk_dim
        movl    $0, 2528(%ecx,%edx,8)   #, <variable>.chunk_dim
        .loc 1 2269 0
        movl    -1980(%ebp), %edi       # dataset,
        movl    52(%edi), %eax  # <variable>.shared, <variable>.shared
        movl    -1948(%ebp), %ecx       # u,
        movl    84(%eax,%ecx,4), %edx   # <variable>.layout.u.chunk.dim,
        xorl    %ecx, %ecx      #
        movl    %edx, -2064(%ebp)       #, D.12819
        movl    %ecx, -2060(%ebp)       #, D.12819
        movl    %edx, %eax      #, tmp302
        movl    %ecx, %edx      #,
        movl    -1948(%ebp), %esi       # u,
        movl    12(%ebp), %edi  # fm,
        addl    28(%edi,%esi,8), %eax   # <variable>.f_dims, tmp302
        adcl    32(%edi,%esi,8), %edx   # <variable>.f_dims,
        addl    $-1, %eax       #, tmp302
        adcl    $-1, %edx       #,
        movl    -2064(%ebp), %esi       # D.12819,
        movl    -2060(%ebp), %edi       # D.12819,
        movl    %esi, 8(%esp)   #,
        movl    %edi, 12(%esp)  #,
        movl    %eax, (%esp)    # tmp302,
        movl    %edx, 4(%esp)   #,
        call    __udivdi3@PLT   #
        movl    -1948(%ebp), %edi       # u,
        movl    12(%ebp), %ecx  # fm,
        movl    %eax, 2260(%ecx,%edi,8) # tmp306, <variable>.chunks
        movl    %edx, 2264(%ecx,%edi,8) #, <variable>.chunks
        .loc 1 2264 0
        addl    $1, %edi        #,
        movl    %edi, -1948(%ebp)       #, u
        cmpl    %edi, -1952(%ebp)       #, f_ndims
        jne     .L246   #,
.LVL84:
.L241:
        .loc 1 2273 0


I'll work on getting a self-contained testcase, but I'm afraid it will take a lot of work.  It's a big library....
Comment 8 Orion Poplawski 2006-04-03 23:21:00 UTC
See URL for download. This is about as good as I can do.  th5s.c is adapted from the th5h.i file that has the failing test.  It is still self-contained and only runs the test that fails.

The rest of the HDF5 library is provided as .i files.  This thing is too complicated for me to split out or reduce much.

Do a "make" to compile.

To see the problem:

gdb test
break H5Dio.c:2264
display fm->chunk_dim

walk through the loop and see that fm->chunk_dim does not get set.

If I compile without -fPIC the test works and fm->chunk_dim gets set.

Comment 9 Uroš Bizjak 2006-09-07 06:58:29 UTC
I have built and run a testsuite of HDF5 library on i686-pc-linux-gnu with:

gcc version 4.2.0 20060906 (experimental)

hdf5-1.6.5 (production):
(CFLAGS="-fno-strict-aliasing" is needed before configure)
All tests PASS with default compile flags out of the box.

hdf5-1.8.0-alpha4:
All tests PASS with defult compile flags out of the box.

I guess this bugreport can be considered as 4.1 regression only.
Comment 10 Andrew Pinski 2006-12-09 22:40:19 UTC
No testcase in over 3 months so closing.