This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: segfaults in libgfortran
- From: "Daniel Franke" <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Wed, 24 Jan 2007 14:52:05 +0100
- Subject: Re: segfaults in libgfortran
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=qZ4yrN5Sif9t/oCCN6cBfERF1r3CCMQ7731TUOLMo6+FaG2eocK5w9GUYoGDNPyYcepr91/a6gmW0LTUz28XS8BZ/MYS0vqZNQ2y36U4pxvIUhT3JlSSl8cINiuCmJTra5oEYGPg+3UZGgDbtZY47rIqNmtX+W1QgemF2IcNuWA=
- References: <640ad44b0701240310h772f1e1an398bac31f5dbaa2a@mail.gmail.com> <45B75E5A.4050401@net-b.de>
2007/1/24, Tobias Burnus <burnus@net-b.de>:
> are segfaults in libgfortran which are triggered by "bad" user code
> considered noteworthy bugs?
If e.g. the format is wrong, libgfortran (at least with checking
options, -Wall etc.) should report this and not crash. (Note that
expensive tests might/should not be enabled by default; I think there
are not that many optional tests currently.)
FCFLAGS=-g -O0 -Wall -Wimplicit-interface -Wunderflow -Wsurprising
-fbounds-check -fimplicit-none
> For example
> WRITE(*, FMT="(' #elements:', I2)") p%data%graph%nused
>
> segfaults if one of the pointer components of p%data%graph%nused is
> not associated, graph in this case (libgfortran/io/write.c:158,
> extract_int).
What do you mean by not associated?
(a) unassociated (i.e. using null() or nullify)?
or
(b) undefined (e.g. deallocated, but not nullified; never assigned
pointer, etc.)
In this case I think the pointer was disassociated, i.e. nullified.
My code is riddled with lines like those shown below (x any type):
IF (ASSOCIATED(x)) THEN
DEALLOCATE(x)
NULLIFY(x)
END IF
and pointers in user defined types are always initialized to null().
Something like -fcheck-pointers (similar to -fcheck-bounds) would come
in quite handy in pointer-heavy code, even if it *only* implements
checking for null().
Regards
Daniel