ianh / owl

A parser generator for visibly pushdown languages.
MIT License
746 stars 21 forks source link

Build errors and warnings #25

Closed WarrenWeckesser closed 3 years ago

WarrenWeckesser commented 3 years ago

I am running PopOS (an Ubuntu derivative):

$ uname -a
Linux pop-os 5.11.0-7620-generic #21~1626191760~20.10~55de9c3-Ubuntu SMP Wed Jul 21 20:34:49 UTC  x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (Ubuntu 10.3.0-1ubuntu1~20.10) 10.3.0
Copyright (C) 2020 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.

When I run make with commit db462c6, I get the following errors and warnings:

$ make
cc -O3 -std=c11 -pedantic -Wall -Wno-missing-braces -Wno-overlength-strings   -o owl src/*.c -ldl
In file included from src/owl.c:9:
src/test.h:12:5: error: unknown type name ‘pid_t’
   12 |     pid_t child;
      |     ^~~~~
In file included from src/test.c:2:
src/test.h:12:5: error: unknown type name ‘pid_t’
   12 |     pid_t child;
      |     ^~~~~
src/test.c: In function ‘spawn_child’:
src/test.c:70:19: warning: implicit declaration of function ‘fdopen’; did you mean ‘fopen’? [-Wimplicit-function-declaration]
   70 |         t->file = fdopen(fd[1], "w");
      |                   ^~~~~~
      |                   fopen
src/test.c:70:17: warning: assignment to ‘FILE *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   70 |         t->file = fdopen(fd[1], "w");
      |                 ^
src/test.c:58:5: warning: ignoring return value of ‘pipe’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   58 |     pipe(fd);
      |     ^~~~~~~~
make: *** [Makefile:24: owl] Error 1

See, for example this stackoverflow question for a discussion of the problem with the definition of pid_t. I can fix that by adding #include <sys/types.h> in src/test.h.

The issue with fdopen is that it is POSIX-only, and not part of C11.

ianh commented 3 years ago

Thanks for filing this. Top of tree (ed55ead) builds cleanly for me now on Linux pop-os 5.13.0-7620-generic #20~1634827117~21.04~874b071-Ubuntu SMP Fri Oct 29 15:06:55 UTC x86_64 x86_64 x86_64 GNU/Linux and seems to work okay, though the test harness is failing with a kernel oops. Let me know if you run into any more problems.

WarrenWeckesser commented 3 years ago

Thanks! It compiles cleanly now.

I also see a bunch of "Segmentation fault (core dumped)", "Aborted (core dumped)" and "critical error" messages in the output files generated by make test. E.g.

warren@pop-os:~/repos/git/forks/owl$ make
cc -O3 -std=c11 -pedantic -Wall -Wno-missing-braces -Wno-overlength-strings   -o owl src/*.c -ldl
warren@pop-os:~/repos/git/forks/owl$ make test
sh -c 'cd test; for i in *.owltest; do ../owl -T "$i" > "results/$i.stdout" 2> "results/$i.stderr"; done;:'
sh -c 'TMP=`mktemp`; cd test; for i in *.owltest; do ../owl -T -c -o "$TMP" "$i" > "results/$i.cc-stdout" 2> "results/$i.cc-stderr"; done; rm "$TMP";:'
git diff --stat --exit-code test/results
 test/results/afl-crash-e.owltest.cc-stderr    |   8 +++-
 test/results/bracket-states.owltest.cc-stderr |   6 +++
 test/results/bracket-states.owltest.cc-stdout |   1 -
 test/results/expr-flat.owltest.cc-stderr      |   8 +++-
 test/results/expr.owltest.cc-stderr           |   8 +++-
 test/results/grammar.owltest.cc-stderr        |   6 +++
 test/results/grammar.owltest.cc-stdout        | 178 --------------------------------------------------------------------------------
 test/results/json.owltest.cc-stderr           |   9 +++-
 test/results/something.owltest.cc-stderr      |   6 +++
 test/results/something.owltest.cc-stdout      |   1 -
 test/results/stmt-crash.owltest.cc-stderr     |   6 +++
 test/results/stmt-crash.owltest.cc-stdout     |   7 ----
 test/results/treehouse.owltest.cc-stderr      |   6 +++
 test/results/treehouse.owltest.cc-stdout      |   1 -
 14 files changed, 55 insertions(+), 196 deletions(-)
make: *** [Makefile:35: test] Error 1

A few of the diffs:

warren@pop-os:~/repos/git/forks/owl$ git diff test/results/json.owltest.cc-stderr
diff --git a/test/results/json.owltest.cc-stderr b/test/results/json.owltest.cc-stderr
index d0bf8c8..a874a2d 100644
--- a/test/results/json.owltest.cc-stderr
+++ b/test/results/json.owltest.cc-stderr
@@ -1,2 +1,7 @@
-parse error: more input needed
-error: 'test executable' exited with status 255
+malloc(): smallbin double linked list corrupted
+Aborted (core dumped)
+<stdin>:1: warning: ISO C forbids an empty translation unit [-Wpedantic]
+cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
+/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
+(.text+0x24): undefined reference to `main'
+collect2: error: ld returned 1 exit status

warren@pop-os:~/repos/git/forks/owl$ git diff test/results/stmt-crash.owltest.cc-stderr
diff --git a/test/results/stmt-crash.owltest.cc-stderr b/test/results/stmt-crash.owltest.cc-stderr
index e69de29..2160bbb 100644
--- a/test/results/stmt-crash.owltest.cc-stderr
+++ b/test/results/stmt-crash.owltest.cc-stderr
@@ -0,0 +1,6 @@
+Segmentation fault (core dumped)
+<stdin>:1: warning: ISO C forbids an empty translation unit [-Wpedantic]
+cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
+/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
+(.text+0x24): undefined reference to `main'
+collect2: error: ld returned 1 exit status

warren@pop-os:~/repos/git/forks/owl$ git diff test/results/treehouse.owltest.cc-stderr
diff --git a/test/results/treehouse.owltest.cc-stderr b/test/results/treehouse.owltest.cc-stderr
index e69de29..5211f41 100644
--- a/test/results/treehouse.owltest.cc-stderr
+++ b/test/results/treehouse.owltest.cc-stderr
@@ -0,0 +1,6 @@
+critical error: write to output file failed
+<stdin>:1: warning: ISO C forbids an empty translation unit [-Wpedantic]
+cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
+/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
+(.text+0x24): undefined reference to `main'
+collect2: error: ld returned 1 exit status
ianh commented 3 years ago

Running in valgrind, it looks like the test harness was writing generated source code to the old, closed FILE instead of the file created by fdopen. I'm surprised this ever worked (across three different OSes, no less!). In any case, I'm seeing all the tests pass on PopOS using 1c131b9.

WarrenWeckesser commented 3 years ago

Great, all tests pass now.