dworkin / lpc-ext

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

JIT .ll code error #13

Closed nyankers closed 2 years ago

nyankers commented 2 years ago

While testing the other issue, I noticed after cleaning the JIT cache, another program was failing. After a whole lot of trial and error, this seems to be the minimum function to cause the problem:

atomic void t()
{
    int a, b;

    for (a=1; a--;) {
        sscanf("3", "%d", b);
        catch(b = 3);
    }
}

This results in (after compiling twice and calling f() on it, for some reason?) an error much like the following:

cache/05/05843706b1e0936d55143796c287a630.ll:51:42: error: use of undefined value '%l1m34'
        %l1r24 = call i32 %c9(i8* %f, i8 2, i32 %l1m34)
                                                ^
1 error generated.
dworkin commented 2 years ago

This is a variant of the same problem, but now in the context of the JIT compiler. b = 0; before the loop should solve the problem. Either DGD has to generate an initializer for b, or the JIT compiler has to.

dworkin commented 2 years ago

I didn't have time to test this until today; should be fixed by https://github.com/dworkin/lpc-ext/commit/1bbfa35f3ec299f80382dda3136a64a75cd58416.

nyankers commented 2 years ago

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

Now I just need to convince clang to stop crashing. I think my server has a super old version for some reason...

dworkin commented 2 years ago

Looks like it's fixed now, thanks! ^^ Now I just need to convince clang to stop crashing. I think my server has a super old version for some reason...

@nyankers The JIT compiler should work with clang 3.8 and later. The crashing may be due to a malformatted LLVM source code file. Feel free to open an issue for it, if you can identify the actual .ll file.

nyankers commented 2 years ago

Ah, I'd deleted them when I cleared the cache, but sure thing. I wish there was an easier way to know which program goes with which .ll code, like if it could be commented in or something.

As far as I'm aware, dgd doesn't even send the program path (since JIT wouldn't be able to meaningfully use it anyway), but it's been a little while since I poked around there.

nyankers commented 2 years ago

Ah, I spoke too soon. After the above change, cloud-server seems to throw a JIT error on boot-up and login as admin. Checking out before the above change, the error doesn't show up.

cache/22/228431a7bf3200b00fceb59b3bda826a.ll:6800:23: error: use of undefined value '%t140'
        %c193 = icmp sge i32 %t140, %t141
                             ^

It looks like the program failing might be /kernel/lib/wiztool.c. I didn't catch this at first because only admin uses that lib on my normal server, only saw it while trying to recreate another issue. ^^;

dworkin commented 2 years ago

I reproduced it, it is indeed wiztool.c.

dworkin commented 2 years ago

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

nyankers commented 2 years ago

Looks like it is, thanks!