Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

illegal hardware instruction (core dumped) when running rift init #15

Closed
merc1er opened this issue Feb 10, 2023 · 25 comments
Closed

illegal hardware instruction (core dumped) when running rift init #15

merc1er opened this issue Feb 10, 2023 · 25 comments

Comments

@merc1er
Copy link

merc1er commented Feb 10, 2023

When running rift init on Ubuntu 22 (Python 3.10), I am getting the following error:

➜  rift rift init
[1]    26906 illegal hardware instruction (core dumped)  rift init

Could you specify what environment is supposed to run on?

@LaDoger
Copy link

LaDoger commented Feb 10, 2023

Me too! Is there a specific required OS or Python version?

@AminRezaei0x443
Copy link
Member

Thanks for reporting the bug! Could you kindly share the result of cat /proc/cpuinfo? flags for one core are sufficient.

@AminRezaei0x443
Copy link
Member

If you're on windows try getting HwInfo software and share an screenshot of the features part.

@merc1er
Copy link
Author

merc1er commented Feb 11, 2023

If you're on windows try getting HwInfo software and share an screenshot of the features part.

I'm on macOS and Linux. @LaDoger maybe you can try this on Windows.

@merc1er
Copy link
Author

merc1er commented Feb 11, 2023

Thanks for reporting the bug! Could you kindly share the result of cat /proc/cpuinfo? flags for one core are sufficient.

~ cat /proc/cpuinfo 
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 49
model name	: DO-Regular
stepping	: 0
microcode	: 0x1000065
cpu MHz		: 1996.247
cache size	: 512 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr wbnoinvd arat npt nrip_save umip rdpid
bugs		: sysret_ss_attrs null_seg spectre_v1 spectre_v2 spec_store_bypass retbleed
bogomips	: 3992.49
TLB size	: 1024 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

@LaDoger
Copy link

LaDoger commented Feb 12, 2023

I can't even get to this point on Windows! I get:
ImportError: Wasmer is not available on this system

@LaDoger
Copy link

LaDoger commented Feb 12, 2023

On Linux I get illegal hardware instruction (core dumped) too.

@LaDoger
Copy link

LaDoger commented Feb 12, 2023

@AminRezaei0x443 I really need this Rift lang to work! FunC is killing me!😩😩😩

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

I can't even get to this point on Windows! I get:

ImportError: Wasmer is not available on this system

Right, I am getting this on macOS too (see #14).

@AminRezaei0x443
Copy link
Member

@merc1er Could you please run and share the output of this code?

from rift.runtime.riftlib import RiftLibSetup
print(RiftLibSetup.determine_lib())
print(RiftLibSetup.get_env_info())

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

@merc1er Could you please run and share the output of this code?

from rift.runtime.riftlib import RiftLibSetup
print(RiftLibSetup.determine_lib())
print(RiftLibSetup.get_env_info())
In [1]: from rift.runtime.riftlib import RiftLibSetup
   ...: print(RiftLibSetup.determine_lib())
https://github.com/AminRezaei0x443/ton/releases/download/v0.1.0/rift-lib-ubuntu-22.04.so

In [2]: print(RiftLibSetup.get_env_info())
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[2], line 1
----> 1 print(RiftLibSetup.get_env_info())

File /usr/local/lib/python3.10/dist-packages/rift/runtime/riftlib.py:90, in RiftLibSetup.get_env_info(cls)
     87 @classmethod
     88 def get_env_info(cls):
     89     return {
---> 90         "libs": cls.get_shared_libs(),
     91         "glibc": cls.get_glibc_version(),
     92     }

File /usr/local/lib/python3.10/dist-packages/rift/runtime/riftlib.py:69, in RiftLibSetup.get_shared_libs(cls)
     67 @classmethod
     68 def get_shared_libs(cls):
---> 69     ok, res = cls._call_get("ldconfig -p")
     70     if not ok:
     71         raise RuntimeError("Error fetching shared libraries!")

File /usr/local/lib/python3.10/dist-packages/rift/runtime/riftlib.py:57, in RiftLibSetup._call_get(cls, command)
     55 @classmethod
     56 def _call_get(cls, command):
---> 57     p = subprocess.Popen(
     58         command,
     59         stdout=subprocess.PIPE,
     60         stderr=subprocess.PIPE,
     61     )
     62     out, err = p.communicate()
     63     if p.returncode == 0:

File /usr/lib/python3.10/subprocess.py:969, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)
    965         if self.text_mode:
    966             self.stderr = io.TextIOWrapper(self.stderr,
    967                     encoding=encoding, errors=errors)
--> 969     self._execute_child(args, executable, preexec_fn, close_fds,
    970                         pass_fds, cwd, env,
    971                         startupinfo, creationflags, shell,
    972                         p2cread, p2cwrite,
    973                         c2pread, c2pwrite,
    974                         errread, errwrite,
    975                         restore_signals,
    976                         gid, gids, uid, umask,
    977                         start_new_session)
    978 except:
    979     # Cleanup if the child failed starting.
    980     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File /usr/lib/python3.10/subprocess.py:1845, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
   1843     if errno_num != 0:
   1844         err_msg = os.strerror(errno_num)
-> 1845     raise child_exception_type(errno_num, err_msg, err_filename)
   1846 raise child_exception_type(err_msg)

FileNotFoundError: [Errno 2] No such file or directory: 'ldconfig -p'

@AminRezaei0x443
Copy link
Member

It's weird. Try to run this command so the core dump includes pid in it.

sudo sysctl -w kernel.core_uses_pid=1

System should dump the core under a file named core.<pid> in the directory you're executing. Now, use gdb so we can find out which instruction is causing this problem.

gdb program core.<pid>

Change the layout to asm with this command inside gdb so you can find the instruction code:

layout asm

Share the result so I can assist further. If you have issues with gdb you can share the core dump with me so I can take a look (Telegram: https://t.me/Amin0x443)

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

No file was created by the command:

~ sudo sysctl -w kernel.core_uses_pid=1
kernel.core_uses_pid = 1

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

By the way, I am using a fresh install of Ubuntu 22 on a Digital Ocean server. If that's easier, you can either spin up your own or I can give you access to mine (it's fresh, almost nothing installed) if give me an SSH public key.

Also, I've no idea of how Rift works, but seems like it is doing a lot of low level system calls. So it would probably be best to have it dockerized.

@AminRezaei0x443
Copy link
Member

Yes, that command just does the configuration. You should run rift init to cause a core dump. But no need, I have access to digital ocean servers so I'll check that myself.

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

Ah ok. I am unable to run rift init though.

➜  rift sudo sysctl -w kernel.core_uses_pid=1
kernel.core_uses_pid = 1
➜  rift rift init                            
[1]    37332 illegal hardware instruction (core dumped)  rift init

@AminRezaei0x443
Copy link
Member

Didn't it create a file in the directory you were working?

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

Didn't it create a file in the directory you were working?

No:

Screenshot 2023-02-12

@AminRezaei0x443
Copy link
Member

Run this:
cat /proc/sys/kernel/core_pattern
It should show the core dumps pattern.

@merc1er
Copy link
Author

merc1er commented Feb 12, 2023

~ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E

@AminRezaei0x443
Copy link
Member

You can find the core at /var/lib/apport/coredump/ but never mind, I figured it out, it's caused by an AVX-512 instruction. Working on the fix!

@AminRezaei0x443
Copy link
Member

This issue is now fixed in the current release. Run pip install -U rift-framework to upgrade. Let me know about the result.

@merc1er
Copy link
Author

merc1er commented Feb 13, 2023

This issue is now fixed in the current release. Run pip install -U rift-framework to upgrade. Let me know about the result.

Great! Thanks! I can confirm upgrading rift fixes the illegal hardware issue.

I can probably close this issue, however when compiling the contract with rift build I am getting a KeyError:

➜  project git:(main) rift build contracts/bare_template.py 
Building contracts/bare_template.py from bare-template project ...
Traceback (most recent call last):
  File "/usr/local/bin/rift", line 8, in <module>
    sys.exit(entry())
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/rift/cli/commands/build.py", line 55, in build
    config.contracts[target],
KeyError: 'contracts/bare_template.py'

@AminRezaei0x443
Copy link
Member

Great, so this issue is resolved. The other issue you mentioned is not an error. You should provide a target name, not a target path. Use:

rift build bare_template

And it will work. You can use all target to build all contracts.

@AminRezaei0x443
Copy link
Member

Closing the issue as It's resolved, Thanks for your help. I will also try to output better message for the new error you shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants