H4ck3rm1k3's Blog

exploration of free/libre open source software and things

gccgo emacs go error message — April 9, 2015

gccgo emacs go error message

The gccgo runtime produces errors like this :

goroutine 18 [runnable]:
created by run_time.$init3
/home/h4ck3rm1k3/testgo2/src/github.com/h4ck3rm1k3/gocore/run_time/proc.go:116

Error message

I am matching them like this :

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won’t work right.
‘(compilation-error-regexp-alist
(quote
(absoft ada aix ant bash borland python-tracebacks-and-caml comma cucumber msft edg-1 edg-2 epc ftnchek iar ibm irix java jikes-file maven jikes-line gcc-inc\
lude ruby-Test::Unit gnu lcc makepp mips-1 mips-2 msft omake oracle perl php rxp sparc-pascal-file sparc-pascal-line sparc-pascal-example sun sun-ada watcom 4bsd\
gcov-file gcov-header gcov-nomark gcov-called-line gcov-never-called perl–Pod::Checker perl–Test perl–Test2 perl–Test::Harness weblint go-test
(” \\(/[a-zA-Z/0-9._]+\\):\\([0-9]+\\)” 1 2 nil 2))))
‘(diff-switches “-u”))

see:

http://www.let.rug.nl/~kleiweg/go/go-emacs.html

Test random permutations of files and lines for gccgo golang go compiler bug reporting — March 31, 2015

Test random permutations of files and lines for gccgo golang go compiler bug reporting

If you are trying to debug a crash of the compiler you need to reduce your test case to something small.

Compiler writers cannot just take your huge project and find the crash.

For go (golang), at least the gccgo compiler,  you pass in a set of files and they are compiled in a package, so the number of files passed to the compiler matters.

I have two simple bash scripts to provoke a compiler crash by first selecting pairs of files to compile and testing them.

After you found the files, you can concatenate them together and select random lines until you can find the exact minimum lines to provoke a crash.

We are using the command shuf from GNU coreutils (https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html) to create random permutations, then use “head -$COUNT” to select COUNT lines from that permutation. This will pick random lines from an input. Then we look for the line “report” in the stderr to look for a sign of the crash, this will end the loop. The program stops when it finds a crash.

Here is the one to select files to compile

rm stop.txt
touch stop.txt
while [ $(wc -l stop.txt | cut -f1 -d ” “) -eq 0 ];
do echo test;
ls *.go | shuf | head -2 | tee test.txt | xargs ~/install/bin/gccgo > out.txt 2>err.txt;
echo $?;
grep report out.txt err.txt > stop.txt;
done

This takes a file with arg 1 and selects n lines with arg 2

rm stop.txt
touch stop.txt
while [ $(wc -l stop.txt | cut -f1 -d ” “) -eq 0 ];
do echo .;
echo “package main” > ~/test.go
cat $1 | shuf | head -$2 >> ~/test.go
~/install/bin/gccgo ~/test.go > out.txt 2>err.txt;
grep report out.txt err.txt > stop.txt;
done

cat ~/test.go # show the error

Feedback :