Stream: bugs

Topic: malloc(): unsorted double linked list corrupted


view this post on Zulip conradin laux (Dec 20 2024 at 16:49):

I get a memory corruption that is potentially related to https://github.com/roc-lang/roc/issues/7083

 python3 -c "print('1\n' * 532 + '\n' + ','.join(['1'] * 21))" > testfile
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.17.0/lZFLstMUCUvd5bjnnpYromZJXkQUrdhbva4xdBInicE.tar.br" }

import pf.Stdout
import pf.File

parseLine = \line ->
    line |> Str.splitOn "," |> List.mapTry Str.toI64

constructComesBefore = \elems ->
    List.walk
        elems
        (Dict.empty {})
        (\acc, a ->
            Dict.insert acc a (Set.empty {}))

parse = \s ->
    lines = Str.splitOn s "\n"
    split = List.findFirstIndex? lines (Str.isEmpty)
    ordering =
        List.takeFirst lines split
        |> List.mapTry? (\_ -> Ok 1)
        |> constructComesBefore
    pageNumbers =
        List.dropFirst lines (split + 1)
        |> List.dropIf Str.isEmpty
        |> List.mapTry? parseLine
    Ok { ordering, pageNumbers }

main =
    when File.readUtf8! "testfile" |> parse is
        Ok contents ->
            contents.pageNumbers
            |> List.len
            |> Num.toStr
            |> Stdout.line!

        Err _ -> Task.ok {}
 roc dev ./err.roc --linker=legacy
malloc(): unsorted double linked list corrupted
❯ roc version
roc nightly pre-release, built from commit 97ab13e on Mi 18 Dez 2024 09:02:06 UTC

OS is Linux 6.12.4, Glibc version is 2.40

view this post on Zulip Anton (Dec 20 2024 at 16:54):

Thanks for reporting @conradin laux, I have not looked at #7083 in depth, can you share why you believe this case is related to #7083?

view this post on Zulip conradin laux (Dec 20 2024 at 17:00):

I have not looked at #7083 in depth, and the error message is different. However the origin of the error itself is from malloc. I think in both cases memory is corrupted in some way that malloc doesn't like, I am unsure if it's the same root cause.

view this post on Zulip Anton (Dec 20 2024 at 17:11):

Can you paste your first message into a github issue for easy tracking and search in the future?

view this post on Zulip conradin laux (Dec 20 2024 at 17:31):

Done! #7393


Last updated: Jul 06 2025 at 12:14 UTC