This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: segfaults in libgfortran


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]