I was searching the Web for system programming languages, found BitC
and decided to rsync it out. However, I encountered a few bugs and
investigated them a little. I couldn't find a bug tracker, so I
thought I'd post my findings here. For the record, I'm running the
AMD64 version of Ubuntu Linux.

1. This is the most obvious one: lib64/libbitc.bita is missing
whitespace after import statements, resulting in lines such as
"(importbitc.stdio as stdio)".

2. Reading a character from standard input often segfaults. The cause
is libbitc/stdio.c and a null/uninitialized pointer. Placing
assert(ios->f) right after fix_stdio_stream(ios) _sometimes_ catches a
null pointer. This is pretty strange, because

struct ty_bitc_stdioStream {
  FILE *f;
} ;
static ty_bitc_stdioStream our_stdin = { 0 };
ty_bitc_stdioStream *bitc_stdio_stdin  = &our_stdin;
static inline void
fix_stdio_stream(ty_bitc_stdioStream *ios)
{
  if (ios->f == 0) {
    if (ios == &our_stdin)
      ios->f = stdin;
...

would appear to be correct. Debugging is quite difficult because
adding just one assertion may "correct" the behaviour. GDB blames the
line "result = fread(&encoded[0], 1, 1, ios->f)", as expected.
However, ios->f wasn't null at this time. After disabling garbage
collection, Valgrind seems to agree. (Otherwise it appears to segfault
on garbage collection.)

The bitc file I used looked like this:
(bitc-version "0.10")
(import bitc.main as main)
(provide bitc.main main)
(import bitc.stdio as stdio)

(define main.main:(fn (vector string) -> int32)
    (lambda (argvec)
    (stdio.read-char stdio.stdin)
    (stdio.write-string stdio.stdout "hello")
    (stdio.write-char stdio.stdout #\linefeed)
    0))

3. This is not a bug per se, but rather an usability nitpick. I had to
read the source to find out how to make bitcc find its libraries from
a nonstandard --prefix location and to output C code.


Anyway, BitC is certainly an extremely interesting project, and I
might be able to contribute at least by sending bugfixes. Where would
you like bug reports and patches to be sent?

Aleksi Nurmi
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to