public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/53478] gfortran segfaults when module name clashes with C binding name of procedure
Date: Thu, 24 May 2012 18:06:00 -0000	[thread overview]
Message-ID: <bug-53478-4-mOy1PEgZXB@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53478-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53478

--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2012-05-24 17:57:26 UTC ---
On Thu, May 24, 2012 at 05:23:50PM +0000, kargl at gcc dot gnu.org wrote:
> #1  0x000000000050aa91 in gfc_verify_binding_labels (sym=0x203cd1280)
>     at ../../gcc4x/gcc/fortran/resolve.c:9847
> 9847              if (sym->attr.if_source == IFSRC_DECL 
> (gdb) list
> 9842
> 9843          bind_c_sym = gfc_find_gsymbol (gfc_gsym_root,
> sym->binding_label);
> 9844          if (bind_c_sym != NULL 
> 9845              && strcmp (bind_c_sym->name, sym->binding_label) == 0)
> 9846            {
> 9847              if (sym->attr.if_source == IFSRC_DECL 
> 9848                  && (bind_c_sym->type != GSYM_SUBROUTINE 
> 9849                      && bind_c_sym->type != GSYM_FUNCTION) 
> 9850                  && ((sym->attr.contained == 1 
> 9851                       && strcmp (bind_c_sym->sym_name, sym->name) != 0) 
> (gdb) print *bind_c_sym
> $1 = {priority = 41101, left = 0x0, right = 0x0, name = 0x20400bf80 "exports", 
>   sym_name = 0x0, mod_name = 0x0, binding_label = 0x0, type = GSYM_MODULE, 
>   defined = 1, used = 0, where = {nextc = 0x203ca61f8, lb = 0x203ca61a0}, 
>   ns = 0x203c62c00}
> 
> Note, sym->binding_label is 0x0


This patch allows the code to compile.  I haven't
tried to construct a longer example that may show
that the module name  may collide with the C binding
name.


Index: resolve.c
===================================================================
--- resolve.c   (revision 187464)
+++ resolve.c   (working copy)
@@ -9848,6 +9848,8 @@ gfc_verify_binding_labels (gfc_symbol *s
               && (bind_c_sym->type != GSYM_SUBROUTINE 
                   && bind_c_sym->type != GSYM_FUNCTION) 
               && ((sym->attr.contained == 1 
+                  && bind_c_sym->sym_name != NULL
+                  && sym->name != NULL
                    && strcmp (bind_c_sym->sym_name, sym->name) != 0) 
                   || (sym->attr.use_assoc == 1 
                       && (strcmp (bind_c_sym->mod_name, sym->module) != 0))))


  parent reply	other threads:[~2012-05-24 17:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 17:08 [Bug fortran/53478] New: " solomon.gibbs.lists at gmail dot com
2012-05-24 17:45 ` [Bug fortran/53478] " kargl at gcc dot gnu.org
2012-05-24 18:06 ` sgk at troutmask dot apl.washington.edu [this message]
2012-05-24 18:53 ` sgk at troutmask dot apl.washington.edu
2012-06-25 12:06 ` dominiq at lps dot ens.fr
2013-04-15 10:06 ` aron at ahmadia dot net
2013-04-15 11:01 ` burnus at gcc dot gnu.org
2013-05-20 20:14 ` burnus 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-53478-4-mOy1PEgZXB@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).