SIGILL in arithmetic code #445

Closed
opened 2024-07-12 03:59:35 +00:00 by xddxdd · 4 comments

Describe the bug

Lix crashes with SIGILL when evaluating certain expressions.

dmesg message:

[ 3503.611074] traps: nix-instantiate[526663] trap invalid opcode ip:7f97ea75cf28 sp:7ffc002d3c30 error:0 in liblixexpr.so[7f97ea687000+1b5000]

Coredump stack trace: https://pb.ltn.pw/M9ivd3mz

Steps To Reproduce

  1. Download https://gist.github.com/duairc/5c9bb3c922e5d501a1edb9e7b3b845ba to net.nix
  2. Run nix-instantiate --eval -E 'with import <nixpkgs> { }; let net = callPackage ./net.nix {}; in net.lib.net.cidr.host 123 "fe80::/10"'

Expected behavior

It should evaluate instead of crashing. Evaluation result on Nix 2.18.4: "fe80::7b"

nix --version output

nix (Lix, like Nix) 2.90.0

Additional context

Add any other context about the problem here.

## Describe the bug Lix crashes with SIGILL when evaluating certain expressions. dmesg message: ``` [ 3503.611074] traps: nix-instantiate[526663] trap invalid opcode ip:7f97ea75cf28 sp:7ffc002d3c30 error:0 in liblixexpr.so[7f97ea687000+1b5000] ``` Coredump stack trace: https://pb.ltn.pw/M9ivd3mz ## Steps To Reproduce 1. Download https://gist.github.com/duairc/5c9bb3c922e5d501a1edb9e7b3b845ba to `net.nix` 2. Run `nix-instantiate --eval -E 'with import <nixpkgs> { }; let net = callPackage ./net.nix {}; in net.lib.net.cidr.host 123 "fe80::/10"'` ## Expected behavior It should evaluate instead of crashing. Evaluation result on Nix 2.18.4: `"fe80::7b"` ## `nix --version` output ``` nix (Lix, like Nix) 2.90.0 ``` ## Additional context Add any other context about the problem here.
xddxdd added the
bug
label 2024-07-12 03:59:35 +00:00
Owner

duplicate of this, but, wtf, nixpkgs should not be relying on overflow semantics, especially given our integers are signed.

#423

@janik i believe this is your code

duplicate of this, but, *wtf*, nixpkgs should *not* be relying on overflow semantics, especially given our integers are signed. https://git.lix.systems/lix-project/lix/issues/423 @janik i believe this is your code
Member

Hey, I have been working on lib.network which should be unrelated https://github.com/NixOS/nixpkgs/pull/318712

The issue above is talking about a gist, that isn't related to nixpkgs afaict, in nixpkgs we are using a toml parsing hack to convert from base10 to base16.

Hey, I have been working on `lib.network` which should be unrelated https://github.com/NixOS/nixpkgs/pull/318712 The issue above is talking about a gist, that isn't related to nixpkgs afaict, in nixpkgs we are using a toml parsing hack to convert from base10 to base16.
Owner

anyway. we're closing this as duplicate and we would additionally argue that the code doing the overflow is broken, itself, because stuff overflowing an i64 is itself not usually a sign of correctness.

the nixpkgs lib stuff that janik wrote may be a suitable replacement for this gist.

anyway. we're closing this as duplicate and we would additionally argue that the code doing the overflow is broken, itself, because stuff overflowing an i64 is itself not usually a sign of correctness. the nixpkgs lib stuff that janik wrote may be a suitable replacement for this gist.
jade added the
Status
invalid
label 2024-07-12 11:21:19 +00:00
jade closed this issue 2024-07-12 11:21:23 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1596 ("language: cleanly ban integer overflows")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/1596", "number": 1596, "kind": "commit message"}], "cl_meta": {"1596": {"change_title": "language: cleanly ban integer overflows"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1596](https://gerrit.lix.systems/c/lix/+/1596) ("language: cleanly ban integer overflows")
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#445
No description provided.