Is there a problem with using modules under gfortran4.9.2 - gfortran

I have a problem with gfortran 4.9.2
I don't have this problem with gfortran 8.2
I don't have this problem under ifort 17.0.6
Unfortunately, I absolutely have to make my work work in gfortran 4.9.2.
I get the following error message :
mpif90 -O0 -g -Wall -fbacktrace -finit-local-zero -ffpe-trap=invalid,zero,overflow -fbounds-check -cpp -fcheck='all' -c main.f
gfortran: internal compiler error: Segmentation error (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:////usr/share/doc/gcc-4.9/README.Bugs> for instructions.
Makefile:160: recipe for target "main.o' failed
make: ***[main.o] Error 4
In particular the use of the modules lead me to the problem:
My failure is absolutely inexplicable.
I managed to get around it by doing the following:
This first code doesn't work
MODULE MOD_1
USE MOD_2
CONTAINS
SUBROUTINE SUB_1
END SUBROUTINE SUB_1
SUBROUTINE SUB_2
END SUBROUTINE SUB_2
END MODULE MOD_1
This seconde code works fine
MODULE MOD_1
CONTAINS
SUBROUTINE SUB_1
USE MOD_2
END SUBROUTINE SUB_1
SUBROUTINE SUB_2
USE MOD_2
END SUBROUTINE SUB_2
END MODULE MOD_1
I simply moved the USE MOD_2 inside the two subroutines
For me it really doesn't make sense. I still have many similar mistakes.
Could someone tell me where to find a description of this problem?
If I knew him more precisely, I might avoid falling back into it!
I hope to have a link to the problem description and possibly the version of the gfortran patch
Sincerely

Related

How do I tell clang memory sanitizer to ignore data from certain libraries?

For example I'd like to ignore sqlite and zlib because I know they're well tested. I grabbed the zpipe.c example and built it like this. Keep in mind I'm using -lz and not building zlib myself. I'm only building zpipe myself and want to limit the sanitize to that one file
clang -g -fsanitize=undefined,memory zpipe.c -lz
I ran echo Test | ./a.out and I got the following error
Uninitialized bytes in __interceptor_fwrite at offset 0 inside [0x7ffd61230bc0, 13)
==50435==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x55767941cd85 in def /tmp/zlib-1.2.12/examples/zpipe.c:70:17
#1 0x55767941e709 in main /tmp/zlib-1.2.12/examples/zpipe.c:186:15
#2 0x7f65e834e30f in __libc_start_call_main libc-start.c
#3 0x7f65e834e3c0 in __libc_start_main#GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2d3c0)
#4 0x5576793981d4 in _start (/tmp/zlib-1.2.12/examples/a.out+0x211d4)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/zlib-1.2.12/examples/zpipe.c:70:17 in def
Is there a way I can say assume any data that goes in and out of zlib or sqlite to be safe to use? I'll be linking both and only want to sanitize my own code
You can use an ignore list file. https://clang.llvm.org/docs/SanitizerSpecialCaseList.html
Usage:
clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c
See the documentation for details on the format of the file.

How to remove error limit in Clang Libtooling?

I made C/C++ source code modification tool using Clang Libtooling. I ran into the following error while executing my tool on test programs.
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
But I would like for the tool to ignore this limit, print all the errors, and execute AST modification as normal. Is there a way to fix this problem using Clang Libtooling?
Thanks to #dratenik, I solved the problem by adding an ArgumentAdjuster which passes Clang the option -ferror-limit=0.
clang::tooling::ClangTool tool(compileDb, filename);
tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster(
"-ferror-limit=0"));
tool.run(...);

Why does dialyzer fail on nocatch?

I ran Dialyzer and got the following error:
Checking whether the PLT /tmp/.BRANCH.service.deps.plt is up-to-date...
{"init terminating in do_boot",
{{case_clause,
{{nocatch,
{dialyzer_error,
[78,111,116,32,97,32,114,101,103,117,108,97,114,32,102,105,108,
101,58,32,
"/usr/lib/erlang/lib/compiler-6.0.3/ebin/beam_a.beam",10]}},
[{dialyzer_plt,compute_md5_from_file,1,
[{file,"dialyzer_plt.erl"},{line,543}]},
{dialyzer_plt,compute_new_md5_1,3,
[{file,"dialyzer_plt.erl"},{line,509}]},
{dialyzer_plt,check_plt1,3,[{file,"dialyzer_plt.erl"},{line,485}]},
{dialyzer_plt,'-subproc/1-fun-0-',1,
[{file,"dialyzer_plt.erl"},{line,603}]}]}},
[{dialyzer_cl,check_plt,3,[{file,"dialyzer_cl.erl"},{line,249}]},
{dialyzer_cl,plt_common,3,[{file,"dialyzer_cl.erl"},{line,182}]},
{dialyzer,'-cl_check_init/1-fun-0-',1,[{file,"dialyzer.erl"},{line,94}]},
{dialyzer,doit,1,[{file,"dialyzer.erl"},{line,236}]},
{dialyzer,plain_cl,0,[{file,"dialyzer.erl"},{line,75}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]}}
What went wrong and how do I fix it? What do the list of integers mean?
The print-out inside the dialyzer_error tuple is an iolist. We can pretty print it using the Erlang shell (started with erl):
1> [78,111,116,32,97,32,114,101,103,117,108,97,114,32,102,105,108,101,58,32].
"Not a regular file: "
2>
You realize it is complaining about bytecode (.beam) from a previous compiler version than the current one I am running. I removed them, and then it ran.

What would cause a compiler to fail randomly?

I am using the clang compiler on windows. I used the installer from the LLVM website. Sometimes it gives me a compiler error.
clang -I./include main.c CoreFoundation.dll
it gives:
In file included from main.c:4:
In file included from ./include\CoreFoundation/CFNumberFormatter.h:110:
./include\CoreFoundation/CFXMLParser.h:159:81: error: unknown type name 'CFXMLNodeRef'
typedef void * (*CFXMLParserCreateXMLStructureCallBack)(CFXMLParserRef parser,
CFXMLNodeRef nodeDesc, void *info);
...
and sometimes this..
In file included from main.c:4:
In file included from ./include\CoreFoundation/CoreFoundation.h:86:
./include\CoreFoundation/CFDateFormatter.h:104:105: error: unknown type name 'CFDateRef'; did you mean 'CFDataRef'?
CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
...
...and other similar warnings, seemingly randomly choosing where to stop. Sometimes it compiles through without error. When it gives an error, they seem to be be about not finding a symbol from an included file. It doesn't complain about not finding the file. But it doesn't consistently stop at the same point and sometimes compiles successfully.
I can reproduce this "error" under Linux with gcc. I even get the "report this compiler bug pls" message.
When it gives an error, they seem to be be about not finding a symbol from an included file
You can get this:
if you compile with multiple threads (eg. make -j8)
if you abort the compile and then start it again without "cleaning" all obj files
if you compiled your source, changed something and compile without "cleaning"
if your compiler/make/build process changes the order every time... (had this with cmake and opencv 3 source)

Why can't I set a breakpoint in my library?

the goal is to debug a method deep within a library.
We can debug c functions in that same library (as long as they are not in the .m files), but apparently no Objective-C code, or even c code within any .m file.
When I try to set breakpoints manually, (break set -n), I get:
WARNING: Unable to resolve breakpoint to any actual locations.
The code does get called, the trusty logger confirms that.
My hunch is that debugging information gets lost somewhere along the way: We are building a static library, then another static library ("Framework" style), and finally we are linking this into our app. Yes, that's complicated but, historical reasons, you know.
I have tried to examine the first .a file to see what is going on, but when I try to load it into lldb I have to create a target. And target creation fails for either architecture:
target create -d --arch i386 libFoo.a
error: 'libFoo.a' doesn't contain the architecture i386
target create -d --arch armv7 libFoo.a
error: 'libFoo.a' doesn't contain any 'remote-ios' platform architectures: arm64, armv7, armv7f, armv7k, armv7s, armv7m, armv7em, armv6m, armv6, armv5, armv4, arm, thumbv7, thumbv7k, thumbv7s, thumbv7f, thumbv7m, thumbv7em, thumbv6m, thumbv6, thumbv5, thumbv4t, thumb
lipo -info libFoo.a
Architectures in the fat file: libFoo.a are: armv7 i386
Does anyone have a good idea how to best tackle this issue? The code is definitely linked, working, but lldb can not set breakpoints.
Thanks a lot
Addendum:
I have created the most simple setup I could think of, and I see very, very odd results:
If I try to lookup certain things, some will return a file and a line number, others will not:
image lookup -s Foo::faz()
1 symbols match 'Foo::faz()' in […]/Build/Products/Debug-iphoneos/Test.app/Test:
Address: Test[0x00010334] (Test.__TEXT.__text + 22060)
Summary: Test'Foo::faz() at Foo.cpp:858
image lookup -s FazBar
1 symbols match 'FazBar' in […]/Build/Products/Debug-iphoneos/Test.app/Test:
Address: Test[0x00038eb4] (Test.__TEXT.__text + 188844)
Summary: Test'FazBar
Trying to set breakpoints in the corresponding files yields, well, expected results:
(lldb) break set -f Foo.cpp -l 877
Breakpoint 5: where = Test'Foo::faz() + 76 at Foo.cpp:877, address = 0x000cb380
(lldb) break set -f bar.c -l 585
Breakpoint 6: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
How can I dig into the .a file to see why certain files are not found?
Well, someone (actually not me, had the absolutely bright idea of setting
GCC_GENERATE_DEBUGGING_SYMBOLS = NO
somewhere hidden deep.
Setting it to yes, well, you guessed it, solves the issue
Alex
set exception break point like above
go to brekpoint navigation click on + and slecte add exception brak point
Try using DYLD_BIND_AT_LOAD environment variable set. This should disable lazy binding, which often fails to hit symbolic breaküpints

Resources