public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
@ 2023-01-31 19:31 kyle.shores44 at gmail dot com
2023-01-31 19:38 ` [Bug libfortran/108618] " pinskia at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-01-31 19:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
Bug ID: 108618
Summary: ISO C-Fortran Interface fails to pass CFI descriptor
version check when using code coverage flags for
fortran
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kyle.shores44 at gmail dot com
Target Milestone: ---
Created attachment 54378
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54378&action=edit
A zipped archive with 5 files, a dockerfile, CMakeLists.txt, a cmake file for
code coverage, a fortran source file, a c++ source file
The C-Fortran interface fails to pass a runtime Fortran check for the CFI
descriptor when checking code coverage. Specifically, the `-fcheck=bounds` flag
causes the runtime failure.
Included is a zip file that has a minimal working example. It's a cmake project
with two source files (one c++, one fortran), a Dockerfile, a CMakeLists.txt
file as well as the necessary code coverage cmake file. Fortran creates some
strings and passes them to C(++) through the `CFI_cdesc_t` struct defined in
ISO_Fortran_binding.h.
Inside of the CMakeLists.txt file there are two calls to
`set(CMAKE_Fortran_FLAGS ...`. Above each is a comment indicating which of the
flags passes and which fails. You can comment and uncomment the pair to watch
the created executable fail intermittently.
When I compile the sources on my machine with the below versions of tools, I
see the failure.
os: macOS 12.5
architecture: Apple M1 Pro
gfortran: GNU Fortran (Homebrew GCC 12.2.0) 12.2.0
g++: (Homebrew GCC 12.2.0) 12.2.0
cmake: 3.25.1
I also see the failure in the Dockerfile included in the zipped archive
(hopefully this aids in the reproducibility of the issue). The tool versions in
the Dockerfile are
os: Fedora Linux 38
architecture: Apple M1 Pro
gfortran: GNU Fortran (GCC) 13.0.1 20230127 (Red Hat 13.0.1-0)
g++: (GCC) 13.0.1 20230127 (Red Hat 13.0.1-0)
cmake: 3.25.2
The specific flag that causes the issue is `-fcheck=bounds`.
The full list of compiler flags passed to gfortran on my machine:
/opt/homebrew/bin/gfortran
-I/Users/kshores/Downloads/mwe/build/_deps/googletest-src/googletest/include
-I/Users/kshores/Downloads/mwe/build/_deps/googletest-src/googletest -g -O0
-fprofile-arcs -ftest-coverage -fcheck=bounds,do,pointer
-ffpe-trap=zero,overflow,invalid -fprofile-abs-path -isysroot
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -c
/Users/kshores/Downloads/mwe/fortran_strings.F90 -o
CMakeFiles/bad_version.dir/fortran_strings.F90.o
The full list of compiler flags passed to gfortran in the Dockerfile:
/usr/bin/gfortran -I/build/_deps/googletest-src/googletest/include
-I/build/_deps/googletest-src/googletest -g -O0 -fprofile-arcs -ftest-coverage
-fcheck=bounds,do,pointer -ffpe-trap=zero,overflow,invalid -fprofile-abs-path
-c /mwe/fortran_strings.F90 -o CMakeFiles/bad_version.dir/fortran_strings.F90.o
I hope that this is enough information. Please let me know if there is more
that is needed from me.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
@ 2023-01-31 19:38 ` pinskia at gcc dot gnu.org
2023-01-31 19:39 ` pinskia at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 19:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Is there a way to remove the depedency on gtest/gtest.h ?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
2023-01-31 19:38 ` [Bug libfortran/108618] " pinskia at gcc dot gnu.org
@ 2023-01-31 19:39 ` pinskia at gcc dot gnu.org
2023-01-31 19:40 ` kyle.shores44 at gmail dot com
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 19:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
and use make rather than cmake here?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
2023-01-31 19:38 ` [Bug libfortran/108618] " pinskia at gcc dot gnu.org
2023-01-31 19:39 ` pinskia at gcc dot gnu.org
@ 2023-01-31 19:40 ` kyle.shores44 at gmail dot com
2023-01-31 19:41 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-01-31 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #3 from Kyle Shores <kyle.shores44 at gmail dot com> ---
Ah, the specific error message printed at runtime:
Fortran runtime error: Unexpected version 16 (expected 1) in CFI descriptor
passed to dummy argument the_names
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (2 preceding siblings ...)
2023-01-31 19:40 ` kyle.shores44 at gmail dot com
@ 2023-01-31 19:41 ` pinskia at gcc dot gnu.org
2023-01-31 19:42 ` kyle.shores44 at gmail dot com
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 19:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
Last reconfirmed| |2023-01-31
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (3 preceding siblings ...)
2023-01-31 19:41 ` pinskia at gcc dot gnu.org
@ 2023-01-31 19:42 ` kyle.shores44 at gmail dot com
2023-01-31 19:54 ` kyle.shores44 at gmail dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-01-31 19:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #4 from Kyle Shores <kyle.shores44 at gmail dot com> ---
Sure, I'll attempt to remove gtest and cmake. I was merely slimming the example
down from my use case in case it mattered.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (4 preceding siblings ...)
2023-01-31 19:42 ` kyle.shores44 at gmail dot com
@ 2023-01-31 19:54 ` kyle.shores44 at gmail dot com
2023-01-31 22:02 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-01-31 19:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #5 from Kyle Shores <kyle.shores44 at gmail dot com> ---
New C++ source file:
```
#include <string_view>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <ISO_Fortran_binding.h>
extern "C" {
void Finit(void);
void get_names( CFI_cdesc_t * );
}
std::vector<std::string_view> extract_names(CFI_cdesc_t* names){
std::vector<std::string_view> vs;
for (int i = 0; i < names->dim[0].extent; i++) {
// determine the length of the string up to the first whitespace character
char* addr = (char *)(names->base_addr) + i * names->elem_len;
char* first_space = strchr(addr, ' ');
size_t strlen = first_space - addr;
vs.push_back(std::string_view(addr).substr(0, strlen));
}
return vs;
}
int main(){
CFI_CDESC_T(1) names;
std::cout << names.version << std::endl;
get_names((CFI_cdesc_t *)&names);
std::cout << names.version << std::endl;
std::vector<std::string_view> vs = extract_names((CFI_cdesc_t *)&names);
for(const auto& elem : vs)
{
std::cout << elem << std::endl;
}
}
```
Makefile:
```
CXX=g++-12
FC=gfortran
CXX_FLAGS=-c -g -O0 -fprofile-arcs -ftest-coverage -fprofile-abs-path
FORT_FLAGS=-c -g -O0 -fprofile-arcs -ftest-coverage -fcheck=bounds,do,pointer
-ffpe-trap=zero,overflow,invalid -fprofile-abs-path
all: cpp fort
${CXX} -o bad_version test.o fortran_strings.o -lgcov -lgfortran
cpp:
${CXX} ${CXX_FLAGS} test.cpp
fort:
${FC} ${FORT_FLAGS} fortran_strings.F90
```
Hope that helps
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (5 preceding siblings ...)
2023-01-31 19:54 ` kyle.shores44 at gmail dot com
@ 2023-01-31 22:02 ` pinskia at gcc dot gnu.org
2023-01-31 22:25 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 22:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 54379
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54379&action=edit
FortranCode
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (6 preceding siblings ...)
2023-01-31 22:02 ` pinskia at gcc dot gnu.org
@ 2023-01-31 22:25 ` pinskia at gcc dot gnu.org
2023-01-31 22:47 ` kyle.shores44 at gmail dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 22:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|WAITING |RESOLVED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
CFI_establish((CFI_cdesc_t *)&names, NULL,
CFI_attribute_pointer,
CFI_type_char, 0, (CFI_rank_t)1, NULL);
Is needed to setup the CFI_cdesc_t originally.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (7 preceding siblings ...)
2023-01-31 22:25 ` pinskia at gcc dot gnu.org
@ 2023-01-31 22:47 ` kyle.shores44 at gmail dot com
2023-01-31 22:49 ` pinskia at gcc dot gnu.org
2023-02-01 15:40 ` kyle.shores44 at gmail dot com
10 siblings, 0 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-01-31 22:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #8 from Kyle Shores <kyle.shores44 at gmail dot com> ---
Thanks for looking into this. I believe that this worked for you, but for me,
on both my machine and in the docker container, that addition did not fix the
problem.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (8 preceding siblings ...)
2023-01-31 22:47 ` kyle.shores44 at gmail dot com
@ 2023-01-31 22:49 ` pinskia at gcc dot gnu.org
2023-02-01 15:40 ` kyle.shores44 at gmail dot com
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 22:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Kyle Shores from comment #8)
> Thanks for looking into this. I believe that this worked for you, but for
> me, on both my machine and in the docker container, that addition did not
> fix the problem.
Where did you put it, before the call to get_names?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug libfortran/108618] ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
` (9 preceding siblings ...)
2023-01-31 22:49 ` pinskia at gcc dot gnu.org
@ 2023-02-01 15:40 ` kyle.shores44 at gmail dot com
10 siblings, 0 replies; 12+ messages in thread
From: kyle.shores44 at gmail dot com @ 2023-02-01 15:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108618
--- Comment #10 from Kyle Shores <kyle.shores44 at gmail dot com> ---
Ah, wait I lied. I must not have recompiled or something because everything
works now. Thank you again for addressing this and sorry for submitting a false
positive.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-02-01 15:40 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 19:31 [Bug libfortran/108618] New: ISO C-Fortran Interface fails to pass CFI descriptor version check when using code coverage flags for fortran kyle.shores44 at gmail dot com
2023-01-31 19:38 ` [Bug libfortran/108618] " pinskia at gcc dot gnu.org
2023-01-31 19:39 ` pinskia at gcc dot gnu.org
2023-01-31 19:40 ` kyle.shores44 at gmail dot com
2023-01-31 19:41 ` pinskia at gcc dot gnu.org
2023-01-31 19:42 ` kyle.shores44 at gmail dot com
2023-01-31 19:54 ` kyle.shores44 at gmail dot com
2023-01-31 22:02 ` pinskia at gcc dot gnu.org
2023-01-31 22:25 ` pinskia at gcc dot gnu.org
2023-01-31 22:47 ` kyle.shores44 at gmail dot com
2023-01-31 22:49 ` pinskia at gcc dot gnu.org
2023-02-01 15:40 ` kyle.shores44 at gmail dot com
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).