tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
267 stars 53 forks source link

Crashed trying to compile standard math library #396

Open 0kenx opened 1 week ago

0kenx commented 1 week ago

https://github.com/ton-blockchain/ton/issues/1019

I suspect this could be a Tact issue, but can't confirm. Using native to bring in fixed248_log2 fails while fixed248_log succeeds.

PS: another independent(?) error:

inline fun fp_ln(x: Int): Int {
    return _native_fixed248_log(x); // ok
}

fun fp_log2(x: Int): Int {
    // return _native_fixed248_log2(x); // this would fail with: Unknown opcode: b1111011
    return _native_fixed96_log(x).fp_div(12345);
}

fails with Fift decompiler crashed Error: Index 224 > 224 is out of bounds but weirdly

- fun fp_log2(x: Int): Int {
+ inline fun fp_log2(x: Int): Int {

succeeds

novusnota commented 6 days ago

This may be a case of outdated libraries, like ton-opcode and others. Try running yarn upgrade (or similar for your package manager) and tell if the issue got resolved or not :)

0kenx commented 6 days ago

No that's not the reason. I've updated everything to latest.

anton-trunov commented 4 days ago

It's most likely a bug in the TVM disassembler that is present in the compilation pipeline. The division TVM instructions are assumed to be always 16-bit wide which is not actually true: https://github.com/tact-lang/ton-opcode/issues/15.

We will fix ton-opcodes and also introduce a config option to switch the disassembly step off: #415.