public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64230] [4.9/5 Regression] Segmentation fault - invalid memory reference in a compiler-generated finalizer for a complicated type hierarchy when a polymorphic variable is allocated in an external procedure. Date: Mon, 15 Dec 2014 19:12:00 -0000 [thread overview] Message-ID: <bug-64230-4-C6IGfyWnFr@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-64230-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64230 janus at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |janus at gcc dot gnu.org --- Comment #2 from janus at gcc dot gnu.org --- Here is a somewhat reduced test case, which gets rid of parts of the insane inheritance chain: Program main Implicit None Type :: t1 End Type Type, Extends (t1) :: t2 Integer, Allocatable :: i End Type Type, Extends (t2) :: t3 Integer, Allocatable :: j End Type Class (t1), Allocatable :: t Allocate (t3 :: t) print *,"allocated!" Deallocate (t) End $ gfortran-5.0 -g -fsanitize=undefined c0.f90 && ./a.out allocated! c0.f90:1: runtime error: member access within null pointer of type 'struct t2' Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x7FC890D235F7 #1 0x7FC890D23C3E #2 0x7FC88F557D9F #3 0x402423 in __final_main_T2 at c0.f90:1 (discriminator 12) #4 0x4015B1 in __final_main_T3 at c0.f90:1 (discriminator 8) #5 0x401806 in MAIN__ at c0.f90:14 (discriminator 3) Speicherzugriffsfehler (Speicherabzug geschrieben) The segfault obviously happens in the deallocate statement, for which -fdump-tree-original shows the following translation: if (t._data == 0B) { _gfortran_runtime_error_at (...); } else { if (t._vptr->_final != 0B) { { struct array0_t1 desc.13; desc.13.dtype = 40; desc.13.data = (void * restrict) t._data; t._vptr->_final (&desc.13, t._vptr->_size, 0); } } __builtin_free ((void *) t._data); } t._data = 0B; (struct __vtype_main_T1 *) t._vptr = &__vtab_main_T1; So, yeah, the problem is somewhere in the finalizer call ("t._vptr->_final"), but I don't directly see where in the finalization routine it occurs (the compiler generates a 500+ line dump for a 15-line program here).
next prev parent reply other threads:[~2014-12-15 19:12 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-64230-4@http.gcc.gnu.org/bugzilla/> 2014-12-08 21:45 ` Joost.VandeVondele at mat dot ethz.ch 2014-12-09 12:38 ` rguenth at gcc dot gnu.org 2014-12-15 19:12 ` janus at gcc dot gnu.org [this message] 2015-01-19 14:10 ` janus at gcc dot gnu.org 2015-01-26 15:57 ` [Bug fortran/64230] [4.9/5 Regression] Invalid memory reference in a compiler-generated finalizer for allocatable component janus at gcc dot gnu.org 2015-01-26 18:54 ` janus at gcc dot gnu.org 2015-01-26 18:55 ` janus at gcc dot gnu.org 2015-01-27 18:37 ` janus at gcc dot gnu.org 2015-01-27 19:50 ` janus at gcc dot gnu.org 2015-04-24 12:39 ` mathewc at nag dot co.uk 2015-04-25 7:49 ` dominiq at lps dot ens.fr 2015-04-27 6:45 ` mathewc at nag dot co.uk
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-64230-4-C6IGfyWnFr@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).