NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.4k stars 12.9k forks source link

nim lockfile generation fails: `SIGBUS: Illegal storage access` #308593

Open MatrixManAtYrService opened 1 month ago

MatrixManAtYrService commented 1 month ago

Describe the bug

Part of packaging a nim application is generating a lockfile for its dependencies. This involves using the nim_lk utility. Instead of generating a lockfile, it does this:

$ nim_lk .
SIGBUS: Illegal storage access. (Attempt to read from nil?)
Bus error: 10

Steps To Reproduce

Steps to reproduce the behavior:

  1. git clone https://github.com/MatrixManAtYrService/nim_lk_bug_apr30.git
  2. cd nim_lk_bug_apr30
  3. nix develop
  4. bash-5.2$ nim_lk ./hello > ./hello/lock.json

Step 4 output:

Cloning into 'packages'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 16 (delta 1), reused 7 (delta 0), pack-reused 0
Receiving objects: 100% (16/16), 163.08 KiB | 632.00 KiB/s, done.
Resolving deltas: 100% (1/1), done.
SIGBUS: Illegal storage access. (Attempt to read from nil?)
Bus error: 10

Expected behavior

  1. git clone https://github.com/MatrixManAtYrService/nim_lk_bug_apr30.git
  2. cd nim_lk_bug_apr30
  3. nix develop
  4. bash-5.2$ nim_lk ./hello > ./hello/lock.json
  5. bash-5.2$ exit
  6. nix run '.#hello'

Step 6 should print "hello world" in fancy ascii-art letters, as seen below

Additional context

I believe that I have the nimble file correct because it builds ok if I don't use nix:

nix develop
bash-5.2$ cd hello/
bash-5.2$ nimble build
  Verifying dependencies for hello@0.1.0
     Info:  Dependency on asciitext@>= 0.0.1 already satisfied
  Verifying dependencies for asciitext@0.0.1
   Building hello/hello using c backend
bash-5.2$ ./hello
 _   _     _____     _         _         _____               _          __ _____     _____     _         _____
| | | |   | ____|   | |       | |       /  _  \             | |        / //  _  \   |  _  \   | |       |  _  \
| |_| |   | |__     | |       | |       | | | |             | |  __   / /| | | |   | |_| |   | |       | | | |
|  _  |   |  __|    | |       | |       | | | |             | | /  | / /| | | |   |  _  /   | |       | | | |
| | | |   | |___    | |___    | |___    | |_| |             | |/   |/ /| |_| |   | | \ \   | |___    | |_| |
|_| |_|   |_____|   |_____|   |_____|   \_____/             |___/|___/\_____/   |_|  \_\  |_____|   |_____/

Notify maintainers

@ehmry @999eagle

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.4.0, macOS 14.4.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/Users/matt/.nix-defexpr/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

ehmry commented 1 month ago

I hate to say this but it works on my machine. If I get the time I'll try to remove more of the Atlas code from nim_lk and that might fix it.

ehmry commented 1 month ago

Does this error still happen if you remove your ~/.nimble directory?

marcusramberg commented 1 month ago

Does this error still happen if you remove your ~/.nimble directory?

Happens for me on aarch64-darwin even if I remove ~/.nimble, works on linux.

MatrixManAtYrService commented 1 month ago

Can confirm what @marcusramberg found. Works on Linux (x86), not on Darwin (arm).

ehmry commented 1 month ago

I'm in the process of a rewriting nim_lk so I won't try to resolve this issue until that is finished.