Stream: bugs

Topic: ✔ Language server memory leak


view this post on Zulip Ian McLerran (Feb 13 2025 at 00:58):

Just discovered a roc language server memory leak. Still trying to minimize the reproduction, but it consistently occurs in the following case:

expect
    parser = zip_6(digit, digit, digit, digit, digit, digit)
    # should be tuple w/ 6 values, not 5.
    parser("123456") |> finalize_lazy == Ok((1, 2, 3, 4, 5))
    # adding a 6th value to the tuple result prevents leak
    # ie: == Ok((1, 2, 3, 4, 5, 6))

Screenshot 2025-02-12 at 18.48.03.png

view this post on Zulip Ian McLerran (Feb 13 2025 at 01:48):

Is it safe to assume that the language server is also on the verge of a rewrite, and therefore reporting bugs in the current language server is effectively kicking a dead horse?

view this post on Zulip Sam Mohr (Feb 13 2025 at 01:52):

I'd say that yes

view this post on Zulip Sam Mohr (Feb 13 2025 at 01:52):

But the horse is dead, so it won't mind

view this post on Zulip Ian McLerran (Feb 13 2025 at 19:21):

LOL! Well while we're kicking that dead horse, I may found another (possibly related, probably not) memory leak in the memory server. It also affects roc check.

alphanumeric_identifier = one_of([
     non_digit_as_arr,
     non_digit_and_identifier_characters,
     identifier_characters_and_non_digit,
     # identifier_characters_and_non_digit_and_identifier_characters,
])

non_digit_as_arr = non_digit |> map(|c| Ok([c]))
non_digit_and_identifier_characters = both(non_digit, identifier_characters) |> map(|(c, cs)| Ok(List.join([[c], cs])))
identifier_characters_and_non_digit = both(identifier_characters, non_digit) |> map(|(cs, c)| Ok(List.join([cs, [c]])))
identifier_characters_and_non_digit_and_identifier_characters = zip_3(identifier_characters, non_digit, identifier_characters) |> map(|(cs1, c, cs2)| Ok(List.join([cs1, [c], cs2])))

The language server identifies all four of those as having the identical type signature. However if I uncomment the 4th element in one_of, the language server balloons to 10's of gigs, and roc check does the same.

view this post on Zulip Ian McLerran (Feb 13 2025 at 19:22):

Totally just kickin' the dead horse here, but this this is driving me nuts, so I came to rant! :triumph::sweat_smile:

view this post on Zulip Ian McLerran (Feb 13 2025 at 19:29):

Worth noting this doesn't just affect the memory server, but again, since we're in the middle of a rewrite, this isn't a long term concern.

view this post on Zulip Notification Bot (Feb 14 2025 at 04:11):

Ian McLerran has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC