tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Segfault when trying examples. #12

Closed adamdecaf closed 9 years ago

adamdecaf commented 9 years ago

Am I doing something wrong?

$ make
g++  -c src/CallGraph.cpp -o obj/CallGraph.o -MMD -MF obj/CallGraph.d -MT obj/CallGraph.o
g++  -c src/IR.cpp -o obj/IR.o -MMD -MF obj/IR.d -MT obj/IR.o
g++  -c src/IRVisitor.cpp -o obj/IRVisitor.o -MMD -MF obj/IRVisitor.d -MT obj/IRVisitor.o
g++  -c src/IRAncestorsPass.cpp -o obj/IRAncestorsPass.o -MMD -MF obj/IRAncestorsPass.d -MT obj/IRAncestorsPass.o
g++  -c src/CodeGen_Bash.cpp -o obj/CodeGen_Bash.o -MMD -MF obj/CodeGen_Bash.d -MT obj/CodeGen_Bash.o
g++  -c src/Parser.cpp -o obj/Parser.o -MMD -MF obj/Parser.d -MT obj/Parser.o
g++  -c src/SymbolTable.cpp -o obj/SymbolTable.o -MMD -MF obj/SymbolTable.d -MT obj/SymbolTable.o
g++  -c src/TypeChecker.cpp -o obj/TypeChecker.o -MMD -MF obj/TypeChecker.d -MT obj/TypeChecker.o
g++ -g -O0 -o bish src/bish.cpp obj/CallGraph.o obj/IR.o obj/IRVisitor.o obj/IRAncestorsPass.o obj/CodeGen_Bash.o obj/Parser.o obj/SymbolTable.o obj/TypeChecker.o
$ cd examples
$ cat fib.bish
def fib(n) {
  if (n < 2) {
    return 1;
  }
  return fib(n-1) + fib(n-2);
}
fib(15);
$ ../bish fib.bish
[1]    63707 segmentation fault  ../bish fib.bish

Here's some info on my setup.

$ uname -a
Darwin Planet-X 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
tdenniston commented 9 years ago

No, that's a bug. Looks like infinite recursion when trying to perform the type check on 'fib'. I'll get a fix in tonight. Thanks for reporting it!

tdenniston commented 9 years ago

Should be working now.

adamdecaf commented 9 years ago

I'm still getting this after a clean and pull.

~/src/third-party/bish/examples $ ../bish fib.bish
segmentation fault: 11
tdenniston commented 9 years ago

I can't reproduce it now with the fib code you posted. Did you make clean and then make? If it persists, can you post a stack trace?

adamdecaf commented 9 years ago

Ah there we go. I forgot to clean, thanks!