Segfault when comparing infinite data structures #330

Open
opened 2024-05-19 01:07:05 +00:00 by gaelan · 1 comment

Describe the bug

When comparing two infinitely nested data structures (and pointer equality doesn't suffice), Lix segfaults.

Steps To Reproduce

let a = rec { foo = [foo]; }; b = rec { foo = [foo]; }; in a == b

Causes Lix to segfault.

Expected behavior

If possible, define a result (I have no idea if there's a sensible argument to be made for either true or false, nor whether there's any way to efficiently determine this result). Otherwise, fail with a nice error instead of segfaulting.

nix --version output

nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab

Additional context

Inherited from Nix, present since at least 2022.

## Describe the bug When comparing two infinitely nested data structures (and pointer equality doesn't suffice), Lix segfaults. ## Steps To Reproduce ``` let a = rec { foo = [foo]; }; b = rec { foo = [foo]; }; in a == b ``` Causes Lix to segfault. ## Expected behavior If possible, define a result (I have no idea if there's a sensible argument to be made for either true or false, nor whether there's any way to efficiently determine this result). Otherwise, fail with a nice error instead of segfaulting. ## `nix --version` output nix (Lix, like Nix) 2.90.0-beta.1-lixpre20240506-b6799ab ## Additional context Inherited from Nix, present since at least 2022.
gaelan added the
bug
label 2024-05-19 01:07:05 +00:00
Owner

defining a result won't really be possible, but we should definitely limit recursion depth on comparisons (lix already does this for the evaluator itself, but comparisons themselves aren't subject to this yet). reusing the same stack depth limit we already have for eval should be fine, and give an obvious place to tune if anyfew run into this trapping.

defining a result won't really be possible, but we should definitely limit recursion depth on comparisons (lix already does this for the evaluator itself, but comparisons themselves aren't subject to this yet). reusing the same stack depth limit we already have for eval should be fine, and give an obvious place to tune if anyfew run into this trapping.
qyriad added the
Area/evaluator
E/help wanted
labels 2024-05-24 21:24:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 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#330
No description provided.