public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault.
@ 2015-10-08 20:33 giorgianb at gmail dot com
  2015-10-08 21:57 ` [Bug fortran/67900] [4.9/5/6 Regression] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: giorgianb at gmail dot com @ 2015-10-08 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67900
           Summary: Interface bug: Binding parameters to C causes a
                    compiler segmentation fault.
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: giorgianb at gmail dot com
  Target Milestone: ---

Created attachment 36465
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36465&action=edit
Compiling this file will cause the compiler to segmentation fault.

A simple interface declaration in which the parameter names are the same and
are binding to C causes the compiler to segfault. Usually when declaring a
generic interface that does the same operation on varied types, it is good
practice to give the parameters the same name.

The program:

program main
        implicit none
        interface f
                function f_real(x)
                        real, bind(c) :: x
                        real :: f_real
                end function f_real

                function f_integer(x)
                        integer, bind(c) :: x
                        integer :: f_integer
                end function f_integer
        end interface f
end program main

Info about gcc:

$ gcc --version
gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Basic machine info:
$ uname -a
Linux localhost.localdomain 4.1.8-200.fc22.x86_64 #1 SMP Tue Sep 22 12:13:21
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
@ 2015-10-08 21:57 ` dominiq at lps dot ens.fr
  2015-10-08 22:01 ` kargl at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-08 21:57 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-08
            Summary|Interface bug: Binding      |[4.9/5/6 Regression]
                   |parameters to C causes a    |Interface bug: Binding
                   |compiler segmentation       |parameters to C causes a
                   |fault.                      |compiler segmentation
                   |                            |fault.
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The Ice appeared between revisions r199034 (2013-05-17):

pr67900.f90:4.33:

                function f_real(x)
                                 1
pr67900.f90:9.36:

                function f_integer(x)
                                    2
Error: Binding label 'x' at (1) collides with global entity 'x' at (2)

and r199221 (2013-05-17, ICE). Likely one of the revisions r199118, r199119, or
r199120 (pr48858 and pr55465). I did not follow the convoluted arguments, but
the code may be invalid: see the audit trail of the two PRs. Good Luck!

Backtrace

* thread #1: tid = 0x44d1226, 0x00007fff90ac7bb0
libsystem_platform.dylib`_platform_strcmp + 176, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff90ac7bb0 libsystem_platform.dylib`_platform_strcmp +
176
libsystem_platform.dylib`_platform_strcmp:
->  0x7fff90ac7bb0 <+176>: movdqa (%rdi,%rcx), %xmm0
    0x7fff90ac7bb5 <+181>: movdqu (%rsi,%rcx), %xmm1
    0x7fff90ac7bba <+186>: pcmpeqb %xmm1, %xmm0
    0x7fff90ac7bbe <+190>: pcmpeqb %xmm2, %xmm1
(lldb) bt
* thread #1: tid = 0x44d1226, 0x00007fff90ac7bb0
libsystem_platform.dylib`_platform_strcmp + 176, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff90ac7bb0 libsystem_platform.dylib`_platform_strcmp +
176
    frame #1: 0x0000000100094f17 f951`(sym=0x0000000141f09680)(gfc_symbol *) +
599 at resolve.c:10783
    frame #2: 0x00000001000bedac f951`::do_traverse_symtree(st=<unavailable>,
st_func=<unavailable>, sym_func=(f951`(null)(gfc_symbol *) at
resolve.c:10735))(gfc_symtree *), void (*)(gfc_symbol *)) + 236 at
symbol.c:3703
    frame #3: 0x00000001000a7f54 f951`::resolve_types(ns=<unavailable>) + 1028
at resolve.c:15336
    frame #4: 0x00000001000a3458 f951`gfc_resolve(ns=0x0000000142015400) + 56
at resolve.c:15416
    frame #5: 0x00000001000a662f f951`::resolve_symbol(sym=0x0000000141f09550)
+ 8479 at resolve.c:13362
    frame #6: 0x00000001000bedac f951`::do_traverse_symtree(st=<unavailable>,
st_func=<unavailable>, sym_func=(f951`::resolve_symbol(gfc_symbol *) at
resolve.c:13482))(gfc_symtree *), void (*)(gfc_symbol *)) + 236 at
symbol.c:3703
    frame #7: 0x00000001000a7d15 f951`::resolve_types(ns=0x0000000144800000) +
453 at resolve.c:15306
    frame #8: 0x00000001000a3458 f951`gfc_resolve(ns=0x0000000144800000) + 56
at resolve.c:15416
    frame #9: 0x000000010008c03b f951`gfc_parse_file() [inlined]
resolve_all_program_units(gfc_global_ns_list=0x0000000144800000) + 71 at
parse.c:5485
    frame #10: 0x000000010008bff4 f951`gfc_parse_file() + 1044
    frame #11: 0x00000001000d19b6 f951`::gfc_be_parse_file() + 54 at
f95-lang.c:209
    frame #12: 0x000000010091e89a f951`::compile_file() + 58 at toplev.c:483
    frame #13: 0x0000000100cfddbc f951`toplev::main(int, char**) + 1151 at
toplev.c:1973
    frame #14: 0x0000000100cfd93d f951`toplev::main(this=<unavailable>, argc=2,
argv=0x00007fff5fbff350) + 717
    frame #15: 0x0000000100cff779 f951`main(argc=2, argv=0x00007fff5fbff350) +
41 at main.c:39


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
  2015-10-08 21:57 ` [Bug fortran/67900] [4.9/5/6 Regression] " dominiq at lps dot ens.fr
@ 2015-10-08 22:01 ` kargl at gcc dot gnu.org
  2015-10-09 12:03 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-08 22:01 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> The Ice appeared between revisions r199034 (2013-05-17):
> 
> pr67900.f90:4.33:
> 
>                 function f_real(x)
>                                  1
> pr67900.f90:9.36:
> 
>                 function f_integer(x)
>                                     2
> Error: Binding label 'x' at (1) collides with global entity 'x' at (2)
> 
> and r199221 (2013-05-17, ICE). Likely one of the revisions r199118, r199119,
> or r199120 (pr48858 and pr55465). I did not follow the convoluted arguments,
> but the code may be invalid: see the audit trail of the two PRs. Good Luck!
> 
> Backtrace
> 
> * thread #1: tid = 0x44d1226, 0x00007fff90ac7bb0
> libsystem_platform.dylib`_platform_strcmp + 176, queue =
> 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
>     frame #0: 0x00007fff90ac7bb0 libsystem_platform.dylib`_platform_strcmp +
> 176
> libsystem_platform.dylib`_platform_strcmp:
> ->  0x7fff90ac7bb0 <+176>: movdqa (%rdi,%rcx), %xmm0
>     0x7fff90ac7bb5 <+181>: movdqu (%rsi,%rcx), %xmm1
>     0x7fff90ac7bba <+186>: pcmpeqb %xmm1, %xmm0
>     0x7fff90ac7bbe <+190>: pcmpeqb %xmm2, %xmm1
> (lldb) bt
> * thread #1: tid = 0x44d1226, 0x00007fff90ac7bb0
> libsystem_platform.dylib`_platform_strcmp + 176, queue =
> 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
>   * frame #0: 0x00007fff90ac7bb0 libsystem_platform.dylib`_platform_strcmp +
> 176
>     frame #1: 0x0000000100094f17 f951`(sym=0x0000000141f09680)(gfc_symbol *)
> + 599 at resolve.c:10783
>     frame #2: 0x00000001000bedac
> f951`::do_traverse_symtree(st=<unavailable>, st_func=<unavailable>,
> sym_func=(f951`(null)(gfc_symbol *) at resolve.c:10735))(gfc_symtree *),
> void (*)(gfc_symbol *)) + 236 at symbol.c:3703
>     frame #3: 0x00000001000a7f54 f951`::resolve_types(ns=<unavailable>) +
> 1028 at resolve.c:15336
>     frame #4: 0x00000001000a3458 f951`gfc_resolve(ns=0x0000000142015400) +
> 56 at resolve.c:15416
>     frame #5: 0x00000001000a662f
> f951`::resolve_symbol(sym=0x0000000141f09550) + 8479 at resolve.c:13362
>     frame #6: 0x00000001000bedac
> f951`::do_traverse_symtree(st=<unavailable>, st_func=<unavailable>,
> sym_func=(f951`::resolve_symbol(gfc_symbol *) at
> resolve.c:13482))(gfc_symtree *), void (*)(gfc_symbol *)) + 236 at
> symbol.c:3703
>     frame #7: 0x00000001000a7d15 f951`::resolve_types(ns=0x0000000144800000)
> + 453 at resolve.c:15306
>     frame #8: 0x00000001000a3458 f951`gfc_resolve(ns=0x0000000144800000) +
> 56 at resolve.c:15416
>     frame #9: 0x000000010008c03b f951`gfc_parse_file() [inlined]
> resolve_all_program_units(gfc_global_ns_list=0x0000000144800000) + 71 at
> parse.c:5485
>     frame #10: 0x000000010008bff4 f951`gfc_parse_file() + 1044
>     frame #11: 0x00000001000d19b6 f951`::gfc_be_parse_file() + 54 at
> f95-lang.c:209
>     frame #12: 0x000000010091e89a f951`::compile_file() + 58 at toplev.c:483
>     frame #13: 0x0000000100cfddbc f951`toplev::main(int, char**) + 1151 at
> toplev.c:1973
>     frame #14: 0x0000000100cfd93d f951`toplev::main(this=<unavailable>,
> argc=2, argv=0x00007fff5fbff350) + 717
>     frame #15: 0x0000000100cff779 f951`main(argc=2, argv=0x00007fff5fbff350)
> + 41 at main.c:39

Patch

Index: resolve.c
===================================================================
--- resolve.c   (revision 228206)
+++ resolve.c   (working copy)
@@ -10702,7 +10702,7 @@ gfc_verify_binding_labels (gfc_symbol *s
       sym->binding_label = NULL;

     }
-  else if (sym->attr.flavor == FL_VARIABLE
+  else if (sym->attr.flavor == FL_VARIABLE && module
           && (strcmp (module, gsym->mod_name) != 0
               || strcmp (sym->name, gsym->sym_name) != 0))
     {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
  2015-10-08 21:57 ` [Bug fortran/67900] [4.9/5/6 Regression] " dominiq at lps dot ens.fr
  2015-10-08 22:01 ` kargl at gcc dot gnu.org
@ 2015-10-09 12:03 ` dominiq at lps dot ens.fr
  2015-10-16  8:22 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-09 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The code compiles without error with the patch in comment 2 without regression.
I have reread the comments in pr48858 and pr55465 and did not convinced myself
that the code is invalid.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
                   ` (2 preceding siblings ...)
  2015-10-09 12:03 ` dominiq at lps dot ens.fr
@ 2015-10-16  8:22 ` rguenth at gcc dot gnu.org
  2015-10-18 21:44 ` mikael at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.9.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
                   ` (3 preceding siblings ...)
  2015-10-16  8:22 ` rguenth at gcc dot gnu.org
@ 2015-10-18 21:44 ` mikael at gcc dot gnu.org
  2015-10-20  0:46 ` kargl at gcc dot gnu.org
  2015-10-20  0:47 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-10-18 21:44 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to kargl from comment #2)
> Index: resolve.c
> ===================================================================
> --- resolve.c   (revision 228206)
> +++ resolve.c   (working copy)
> @@ -10702,7 +10702,7 @@ gfc_verify_binding_labels (gfc_symbol *s
>        sym->binding_label = NULL;
>  
>      }
> -  else if (sym->attr.flavor == FL_VARIABLE
> +  else if (sym->attr.flavor == FL_VARIABLE && module
>            && (strcmp (module, gsym->mod_name) != 0
>                || strcmp (sym->name, gsym->sym_name) != 0))
>      {

There is another instance of this a few lines down where the check for module
!= NULL existed at the time this code was introduced at r199120.
So this patch is at least consistent.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
                   ` (4 preceding siblings ...)
  2015-10-18 21:44 ` mikael at gcc dot gnu.org
@ 2015-10-20  0:46 ` kargl at gcc dot gnu.org
  2015-10-20  0:47 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-20  0:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Tue Oct 20 00:45:48 2015
New Revision: 229014

URL: https://gcc.gnu.org/viewcvs?rev=229014&root=gcc&view=rev
Log:
2015-10-19  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67900
        * resolve.c (gfc_verify_binding_labels): Check for NULL pointer.

2015-10-19  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/67900
        * gfortran.dg/pr67900.f90: New tests.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr67900.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/resolve.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/67900] [4.9/5/6 Regression] Interface bug: Binding parameters to C causes a compiler segmentation fault.
  2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
                   ` (5 preceding siblings ...)
  2015-10-20  0:46 ` kargl at gcc dot gnu.org
@ 2015-10-20  0:47 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-10-20  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org
   Target Milestone|4.9.4                       |5.3

--- Comment #6 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.  Thanks for the bug report.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-10-20  0:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-08 20:33 [Bug fortran/67900] New: Interface bug: Binding parameters to C causes a compiler segmentation fault giorgianb at gmail dot com
2015-10-08 21:57 ` [Bug fortran/67900] [4.9/5/6 Regression] " dominiq at lps dot ens.fr
2015-10-08 22:01 ` kargl at gcc dot gnu.org
2015-10-09 12:03 ` dominiq at lps dot ens.fr
2015-10-16  8:22 ` rguenth at gcc dot gnu.org
2015-10-18 21:44 ` mikael at gcc dot gnu.org
2015-10-20  0:46 ` kargl at gcc dot gnu.org
2015-10-20  0:47 ` kargl at gcc dot gnu.org

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