This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/53478] gfortran segfaults when module name clashes with C binding name of procedure


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))))


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