Skip to content

elm make hang then runaway memory usage from orphan process #2241

Open
Zokka-Dev/zokka-compiler
#20
@javanwood

Description

@javanwood

Quick Summary: Compilation hangs and an elm process remains active after <ctrl-c>. Memory usage of this process reaches >16GB (memory available to system) which bogged down my system.

SSCCE

module Main exposing (..)

foldMap : (a -> b) -> (a -> c) -> (b -> c -> c) -> a -> c
foldMap fab fac fbc a = fac a

break : Float -> (Float, Float)
break input = foldMap identity (\x -> (x, x)) (\( low, high ) x -> ( min low x, max high x )) input
  • Elm: Elm 0.19.1
  • Browser: NA
  • Operating System: macOS 11.4

Additional Details

elm make hangs after printing Compiling .... The orphan elm process only continues if waiting for longer than 5-6 seconds before using to cancel the elm make command.

When changing (\( low, high ) x -> to (\x ( low, high ) -> the snippet compiles as expected, and changing ( min low x, max high x ) to ( x, x ) results in the compiler error `foldMap` needs the 4th argument to be: ( ∞, ∞ ).

Came across this writing a foldMap to calculate the min and max of a List Float but have simplified to get a minimal reproduction.

Love your work!

Activity

github-actions

github-actions commented on Jan 19, 2022

@github-actions

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

maxime-didier

maxime-didier commented on Mar 18, 2022

@maxime-didier

Hello,

We encountered the same problem in our code after I mistakenly swapped the arguments of the set function in a lens. It looks to me that we encountered the same typechecker bug:

module Main exposing (..)

type alias Lens a b =
  { get : a -> b
  , set : b -> a -> a
  }

oopsLens : Lens { b | oops : a } b
oopsLens = Lens .oops (\x oops -> { x | oops = oops })
pete-murphy

pete-murphy commented on Jan 9, 2024

@pete-murphy

Ran into a similar issue, though not from mistakenly swapping arguments, this was from a use of elm-form that I thought would actually compile. Boiled it down to

module Main exposing (..)


type X r
    = X


f : X r -> X { r | y : () }
f _ =
    X


x : X { z : () }
x =
    X


example : ()
example =
    x
        |> (if True then
                f

            else
                identity
           )
        |> always ()

That causes elm make to hang and balloon in memory usage (even after exiting with Ctrl+c).

added a commit that references this issue on Jul 17, 2024
linked a pull request that will close this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @javanwood@pete-murphy@maxime-didier

      Issue actions

        `elm make` hang then runaway memory usage from orphan process · Issue #2241 · elm/compiler