#Segmentation Fault Core dumped

24 messages · Page 1 of 1 (latest)

marble pulsar
#

Been hard stucking on running the follow function as binary in Linux. It can run by mojo run .mojo just fine but it just can’t be executed as a binary … and the only error I got is in the title.

    var ecwords = List[Int](0)*64
    var values = List[Int]()

    for i in range(222):
        var temp: Int = (padded[i] + ecwords[0]) % 929
        for j in range(63, -1, -1):
            var val: Int = temp * EC_LV5[j] % 929
            var factor: Int = ecwords[64-j] if j > 0 else 0
            ecwords[63-j] = (factor + 929 - val) % 929

    return ecwords```
EC_LV5 is 64 bytes of error correction codewords ECL_LV5 = List[Int](….)
spare token
#

Do you have any way of putting this in gdb at the moment? We can try to tease apart where things might be falling over

silent parrot
#

what is the intended value of ecwords?

marble pulsar
spare token
marble pulsar
snow marlin
#

Could you share the full script?

marble pulsar
#

I can run the fn without any issue I couldn’t run it in binary execution form

spare token
marble pulsar
#

Like ./test

marble pulsar
#

Not VM not WSL Ubuntu OS

marble pulsar
#
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Downloading separate debug info for system-supplied DSO at 0x7ffff7fc3000
Downloading separate debug info for /lib/x86_64-linux-gnu/libstdc++.so.6        
Downloading separate debug info for /lib/x86_64-linux-gnu/libgcc_s.so.1         
[Thread debugging using libthread_db enabled]                                   
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6e006c0 (LWP 11477)]
[New Thread 0x7ffff64006c0 (LWP 11478)]
[New Thread 0x7ffff5a006c0 (LWP 11479)]
[New Thread 0x7ffff50006c0 (LWP 11480)]
[New Thread 0x7ffff46006c0 (LWP 11481)]

Thread 1 "errc" received signal SIGSEGV, Segmentation fault.
0x000055555555bf6c in main ()

#

I somehow fixed it by putting var ECL_V5 from outside of the fn into inside of the fn…. Still don’t know what’s the actual reason behind

spare token
#

need debug symbols to diagnose

marble pulsar
#

I discovered that if a variable is outside of the fn it should be defined as alias not var in order to make the binary work. If its defined as var the script can still run with mojo run

native pineBOT
#

Congrats @marble pulsar, you just advanced to level 1!

marble pulsar
marble pulsar
#

As a dude from python took me a while to figure out. And still reading the variables scope thing

spare token
foggy lynx