dworkin / lpc-ext

Extension modules for Hydra and DGD
The Unlicense
9 stars 5 forks source link

JIT clang crash #14

Closed nyankers closed 2 years ago

nyankers commented 2 years ago

I've been able to create a relatively small code example (from an originally much longer program) that causes clang to crash:

void t(string a)
{
    int loop;
    string b;

    if (sscanf(a, "%s", b)) {
        a = b;
    }

    loop = TRUE; /* crashes with or without this line */
    switch (a[0]) {
        case 0:
            while (loop) {
                switch (a[0]) {
                    case 0:
                        break;

                    default:
                        loop = FALSE;
                }
            }
    }
}

This actually causes clang to give a seg fault, so in my opinion, it seems like a clang issue rather than just a dgd issue (even if it's malformed, it shouldn't seg fault...), but you mentioned wanting such reports.

Let me know if you have trouble reproducing it, and I can try to give more details.

dworkin commented 2 years ago

The LLVM team is funny about that. I reported a similar bug early in the development of the JIT compiler, and they didn't look into it for two years. I suppose they consider .ll files an "internal" format, extensive documentation and spammy diagnostic crash messages notwithstanding.

I've reproduced the crash.

dworkin commented 2 years ago

This is actually the same crasher that I've reported, cropping up again... triggered by a bug in the JIT compiler.

nyankers commented 2 years ago

Hmmm, I thought other languages compile into .ll too. If that's their perspective, maybe C-based JIT would be more stable. Maybe I'll play around with that someday, the trouble I ran into with .ll-related stuff is I eventually got it to crash, but I know C a fair bit better.

dworkin commented 2 years ago

Should be fixed by https://github.com/dworkin/lpc-ext/commit/f2738cc4fabbb47c24d7910a09d34504152b80ba.

nyankers commented 2 years ago

Looks like it's fixed now, thanks! ^^