public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/99711] Crash when reading an allocated character array in namelist
Date: Fri, 26 Mar 2021 01:47:28 +0000	[thread overview]
Message-ID: <bug-99711-4-MqY3QxlheZ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99711-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99711

--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
This is interesting, compiling with the -g option for debugging.

Running a test case that is working with:

  character(len=10), dimension(:), allocatable :: cbulist_ru ! explicit char
len

Breakpoint 1, nml_read_obj (dtp=dtp@entry=0x7fffffffd260, 
    nl=nl@entry=0x5184c0, offset=offset@entry=0, 
    pprev_nl=pprev_nl@entry=0x7fffffffd068, 
    nml_err_msg=nml_err_msg@entry=0x7fffffffd100 "Internal namelist read
error", clow=1, chigh=0, nml_err_msg_size=200)
    at ../../../trunk/libgfortran/io/list_read.c:2886
2886      if (dtp->u.p.nml_read_error || !nl->touched)
(gdb) p nl
$1 = (namelist_info *) 0x5184c0
(gdb) p *nl
$2 = {type = BT_CHARACTER, var_name = 0x518530 "cbulist_ru", 
  mem_pos = 0x515e80, dtio_sub = 0x0, vtable = 0x0, touched = 1, len = 1, 
  var_rank = 1, size = 10, string_length = 10, dim = 0x518550, ls = 0x518570, 
  next = 0x0}

string_length as expected.

Running the failing test case with:

  character(len=:), dimension(:), allocatable :: cbulist_ru ! deferred len

Breakpoint 1, nml_read_obj (dtp=dtp@entry=0x7fffffffd240, 
    nl=nl@entry=0x5184c0, offset=offset@entry=0, 
    pprev_nl=pprev_nl@entry=0x7fffffffd048, 
    nml_err_msg=nml_err_msg@entry=0x7fffffffd0e0 "Internal namelist read
error", clow=1, chigh=0, nml_err_msg_size=200)
    at ../../../trunk/libgfortran/io/list_read.c:2886
2886      if (dtp->u.p.nml_read_error || !nl->touched)
(gdb) p nl->string_length 
$13 = 10
(gdb) p *nl
$14 = {type = BT_CHARACTER, var_name = 0x518530 "cbulist_ru", 
  mem_pos = 0x515e80, dtio_sub = 0x0, vtable = 0x0, touched = 1, len = 1, 
  var_rank = 1, size = 967676983855022080, string_length = 10, dim = 0x518550, 
  ls = 0x518570, next = 0x0}
(gdb) p *nl->dim
$15 = {_stride = 1, lower_bound = 1, _ubound = 5}


size is messed up badly.

  parent reply	other threads:[~2021-03-26  1:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 14:02 [Bug fortran/99711] New: " phil1691 at gmail dot com
2021-03-23  1:11 ` [Bug fortran/99711] " jvdelisle at gcc dot gnu.org
2021-03-23  2:11 ` kargl at gcc dot gnu.org
2021-03-23  2:29 ` jvdelisle at gcc dot gnu.org
2021-03-23  2:41 ` jvdelisle at gcc dot gnu.org
2021-03-23  6:16 ` sgk at troutmask dot apl.washington.edu
2021-03-23  7:37 ` philippe.wautelet at aero dot obs-mip.fr
2021-03-24  2:41 ` jvdelisle at gcc dot gnu.org
2021-03-24  3:15 ` jvdelisle at gcc dot gnu.org
2021-03-24  5:35 ` sgk at troutmask dot apl.washington.edu
2021-03-24  5:45 ` sgk at troutmask dot apl.washington.edu
2021-03-25  3:32 ` jvdelisle at gcc dot gnu.org
2021-03-26  1:47 ` jvdelisle at gcc dot gnu.org [this message]
2021-03-26  2:25 ` jvdelisle at gcc dot gnu.org
2021-03-26  2:38 ` jvdelisle at gcc dot gnu.org
2021-03-26  6:04 ` sgk at troutmask dot apl.washington.edu
2021-03-26 23:38 ` jvdelisle at gcc dot gnu.org
2021-03-27  3:14 ` jvdelisle at gcc dot gnu.org
2023-08-31 12:58 ` philippe.wautelet at aero dot obs-mip.fr
2023-08-31 17:20 ` sgk at troutmask dot apl.washington.edu
2023-08-31 17:22 ` kargl at gcc dot gnu.org

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-99711-4-MqY3QxlheZ@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: link
Be 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).