User account creation filtered due to spam.

Bug 38887 - [4.4 Regression] run-time abort for MVBITS with run-time zero sized array arguments
Summary: [4.4 Regression] run-time abort for MVBITS with run-time zero sized array arg...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P4 normal
Target Milestone: 4.4.0
Assignee: Daniel Kraft
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-01-16 21:11 UTC by Dick Hendrickson
Modified: 2009-01-21 13:37 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-01-20 09:44:41


Attachments
Difference of the dump (1.12 KB, text/plain)
2009-01-17 22:20 UTC, Tobias Burnus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2009-01-16 21:11:18 UTC
The following program gives a run-time abort.  If either of the array arguments to MVBITS has an explicit (ie (5,1) or (6,1) ) zero size, the program does not abort.

It aborts differently on Windows, depending on how it is run.

Dick Hendrickson

      program try_ya0013

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

      integer ida(9)
      call ya0013(ida,1,5,6)
      end
      SUBROUTINE YA0013(IDA,nf1,nf5,nf6)
      INTEGER IDA(9)
      IDA = 1
      CALL MVBITS(IDA(NF5:NF1), 0, 1, IDA(NF6:NF1),2)
      END SUBROUTINE


C:gfortran>gfortran try_ya0013.f

C:gfortran>a

When run as a simple stand-alone test, an alert box appears.  The first part is:
"a.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

The box then offers to send a report to Microsoft!


When the subroutine is run as part of a larger program this text message appears:
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."
and the program terminates.
Comment 1 Tobias Burnus 2009-01-16 21:48:38 UTC
Confirm. Thanks for reporting.

Backtrace:
#0  0x00002aaaab4a4645 in raise () from /lib64/libc.so.6
#1  0x00002aaaab4a5c33 in abort () from /lib64/libc.so.6
#2  0x00002aaaaad69c00 in *_gfortrani_internal_unpack_4 (d=0x6e11, src=0x6e11)
    at /home/tob/projects/gcc/libgfortran/generated/in_unpack_i4.c:63
#3  0x0000000000400ba3 in ya0013 (ida=(1, 1, 1, 1, 1, 1, 1, 1, 1), nf1=1, nf5=5, nf6=6) at test.f90:12

Working: 4.4.0 20081029 (experimental) [trunk revision 141421]
Failing: 4.4.0 20081103 (experimental) [trunk revision 141544]
(Assuming that my tree was clean back then)

Daniel, you worked on MVBITS for PR 35681 (Rev. 141516). Could you have a look for this PR and also PR 38883. Thanks!
Comment 2 Tobias Burnus 2009-01-17 22:20:29 UTC
Created attachment 17130 [details]
Difference of the dump

The problem is the call
    _gfortran_internal_unpack (&parm.2, D.1572);
since the array has zero extent. The _gfortrani_internal_unpack_4 has the following check:

61            extent[n] = d->dim[n].ubound + 1 - d->dim[n].lbound;
62            if (extent[n] <= 0)
63              abort ();
Comment 3 Daniel Kraft 2009-01-20 09:44:41 UTC
I will work on this.
Comment 4 Daniel Kraft 2009-01-21 13:35:09 UTC
Subject: Bug 38887

Author: domob
Date: Wed Jan 21 13:34:55 2009
New Revision: 143541

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143541
Log:
2009-01-21  Daniel Kraft  <d@domob.eu>

	* trans-stmt.c (gfc_conv_elemental_dependencies):  Cleaned up comment.

2009-01-21  Daniel Kraft  <d@domob.eu>

	PR fortran/38887
	* runtime/in_unpack_generic.c (internal_unpack):  Return instead of
	abort when called with empty array.
	* m4/in_unpack.m4:  Ditto.
	* generated/in_unpack_i1.c:  Regenerated.
	* generated/in_unpack_i2.c:  Regenerated.
	* generated/in_unpack_i4.c:  Regenerated.
	* generated/in_unpack_i8.c:  Regenerated.
	* generated/in_unpack_i16.c: Regenerated.
	* generated/in_unpack_r4.c:  Regenerated.
	* generated/in_unpack_r8.c:  Regenerated.
	* generated/in_unpack_r10.c: Regenerated.
	* generated/in_unpack_r16.c: Regenerated.
	* generated/in_unpack_c4.c:  Regenerated.
	* generated/in_unpack_c8.c:  Regenerated.
	* generated/in_unpack_c10.c: Regenerated.
	* generated/in_unpack_c16.c: Regenerated.

2009-01-21  Daniel Kraft  <d@domob.eu>

	PR fortran/38887
	* gfortran.dg/mvbits_5.f90:  New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/mvbits_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/in_unpack_c10.c
    trunk/libgfortran/generated/in_unpack_c16.c
    trunk/libgfortran/generated/in_unpack_c4.c
    trunk/libgfortran/generated/in_unpack_c8.c
    trunk/libgfortran/generated/in_unpack_i1.c
    trunk/libgfortran/generated/in_unpack_i16.c
    trunk/libgfortran/generated/in_unpack_i2.c
    trunk/libgfortran/generated/in_unpack_i4.c
    trunk/libgfortran/generated/in_unpack_i8.c
    trunk/libgfortran/generated/in_unpack_r10.c
    trunk/libgfortran/generated/in_unpack_r16.c
    trunk/libgfortran/generated/in_unpack_r4.c
    trunk/libgfortran/generated/in_unpack_r8.c
    trunk/libgfortran/m4/in_unpack.m4
    trunk/libgfortran/runtime/in_unpack_generic.c

Comment 5 Daniel Kraft 2009-01-21 13:37:23 UTC
Fixed on trunk by converting the abort() call in internal_unpack to a return (this is also what the "real" unpack library call does).
Comment 6 hjl@gcc.gnu.org 2009-01-29 17:43:44 UTC
Subject: Bug 38887

Author: hjl
Date: Thu Jan 29 17:43:14 2009
New Revision: 143765

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143765
Log:
2009-01-29  H.J. Lu  <hongjiu.lu@intel.com>

	2009-01-28  Richard Guenther  <rguenther@suse.de>

	PR middle-end/38908
	* g++.dg/warn/Wuninitialized-2.C: New testcase.

	2009-01-27  Daniel Kraft  <d@domob.eu>

	PR fortran/38883
	* gfortran.dg/mvbits_6.f90:  New test.
	* gfortran.dg/mvbits_7.f90:  New test.
	* gfortran.dg/mvbits_8.f90:  New test.

	2009-01-21  Daniel Kraft  <d@domob.eu>

	PR fortran/38887
	* gfortran.dg/mvbits_5.f90:  New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/warn/Wuninitialized-2.C
      - copied unchanged from r143764, trunk/gcc/testsuite/g++.dg/warn/Wuninitialized-2.C
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/mvbits_5.f90
      - copied unchanged from r143764, trunk/gcc/testsuite/gfortran.dg/mvbits_5.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/mvbits_6.f90
      - copied unchanged from r143764, trunk/gcc/testsuite/gfortran.dg/mvbits_6.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/mvbits_7.f90
      - copied unchanged from r143764, trunk/gcc/testsuite/gfortran.dg/mvbits_7.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/mvbits_8.f90
      - copied unchanged from r143764, trunk/gcc/testsuite/gfortran.dg/mvbits_8.f90
Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog