Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elm-19: thread blocked indefinitely in an MVar operation #1789

Open
bburdette opened this issue Sep 6, 2018 · 5 comments
Open

elm-19: thread blocked indefinitely in an MVar operation #1789

bburdette opened this issue Sep 6, 2018 · 5 comments

Comments

@bburdette
Copy link

bburdette commented Sep 6, 2018

I was trying to make some code more generic and ran into this:

elm-19: You ran into a compiler bug. Here are some details for the developers:
[00] 
[00]     ? [rank = 1]
[00] 
[00] Please create an <http://sscce.org/> and then report it
[00] at <https://github.com/elm/compiler/issues>
[00] 
[00] 
[00] CallStack (from HasCallStack):
[00]   error, called at compiler/src/Type/Solve.hs:205:15 in main:Type.Solve
[00] elm-19: thread blocked indefinitely in an MVar operation
[00] (error exit: exit status 1)

So, here's the minimal example that produces the error. Depends on elm-ui v 1.0.0.

Minimal.elm.txt

@akoppela
Copy link

module Main exposing (main)

import Platform


type Form model formData
    = SimpleForm (model -> formData)
    | AdvancedForm (model -> Bool)


initForm : Form model formData -> model -> Maybe formData
initForm formHelper model =
    case formHelper of
        SimpleForm toForm ->
            toForm model

        AdvancedForm _ ->
            Nothing


type alias Model internalModel formData =
    { internalModel : internalModel
    , form : formData
    }


processAction : Form internalModel formData -> Model internalModel formData -> Model internalModel formData
processAction formHelper model =
    { model | form = initForm formHelper model.internalModel }


main : Program () () ()
main =
    Platform.worker
        { init = \_ -> ( (), Cmd.none )
        , update = \_ _ -> ( (), Cmd.none )
        , subscriptions = \_ -> Sub.none
        }

Another example. The issue is that toForm model should be Just (toForm model).

@jonathanfishbein1
Copy link

I'm getting something similar

type Vector a
    = Vector (List a)

type Matrix a
    = Matrix (List (Vector.Vector a))


multiplyComplexMatrices : Matrix (Vector.Vector (ComplexNumbers.ComplexNumberCartesian number)) -> Matrix (Vector.Vector (ComplexNumbers.ComplexNumberCartesian number)) -> Matrix (Vector.Vector (ComplexNumbers.ComplexNumberCartesian number))
multiplyComplexMatrices matrixOne matrixTwo =
    liftA2 Vector.multiplyComplexVectors matrixOne (transpose matrixTwo)

apply : Matrix (a -> b) -> Matrix a -> Matrix b
apply (Matrix fMatrix) (Matrix matrix) =
    Matrix <| List.map2 (\fVector xVector -> Vector.apply fVector xVector) fMatrix matrix


liftA2 : (a -> b -> c) -> Matrix a -> Matrix b -> Matrix c
liftA2 f a b =
    apply (map f a) b

transpose : Matrix a -> Matrix a
transpose (Matrix matrix) =
    matrix
        |> List.map (\(Vector.Vector x) -> x)
        |> List.Extra.transpose
        |> List.map (\x -> Vector.Vector x)
        |> Matrix

map : (a -> b) -> Matrix a -> Matrix b
map f (Matrix matrix) =
    Matrix <| List.map (Vector.map f) matrix

{-| Vector map
-}
map : (a -> b) -> Vector a -> Vector b
map f (Vector vector) =
    Vector <| List.map f vector

ComplexNumber package here

https://package.elm-lang.org/packages/jonathanfishbein1/complex-numbers/latest/ComplexNumbers

@matheus23
Copy link

Hi! I'm interested in automatic reduction of elm codebases, so one does not have to do it by hand, like you did.

I'm working on elm-reduce, which is something similar to creduce as my bachelor's thesis, and I need as much test-data for it as possible.

I would love to get into contact with you, but two of you don't have emails listed on your profile. Would you mind sending me a mail? (You can find the address in my profile)

@bilus
Copy link

bilus commented Jun 1, 2019

Getting the exact same error when using Monocle.Lens. :| It's killing me. I can prepare a simple case if what's above isn't enough.

@tankorsmash
Copy link

I had a similar issue where there was a compiler crash with the MVar issue:

$ elm make .\src\Main.elm --output=/dev/null
Compiling ...elm.exe: .\\Data\\Vector\\Generic\\Mutable.hs:703 (modify): index out of bounds (3,3)
CallStack (from HasCallStack):
  error, called at .\\Data\\Vector\\Internal\\Check.hs:87:5 in vector-0.12.0.1-GC2xzdMF0QQGz7ZCcRBJRL:Data.Vector.Internal.Check

The issue seemed to be that the Elm compiler couldn't figure out the Elm error in my code and crashed, because fixing the issue also made the compile work.

I tried to make an ellie of it, but I couldn't make up an example that was able to reproduce it. It would be on line 70 of this successfully-compiling ellie, if looking at this gives any sort of hint (as unlikely as it is though, since I couldn't reproduce it outside my codebase), where I had foo2 = getLocations m while it should have been foo2 = getLocations m.locations.

I do have a branch saved that reproduces in my 6k line project, if someone on the dev team would like access, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants