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

Array.append causes runtime error on largish arrays #444

Closed
klaftertief opened this Issue Nov 21, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@klaftertief

klaftertief commented Nov 21, 2015

I know there are already some similar Array issues, but I hope to offer a better test case for this specific issue. This is extracted from issues working on a polyline simplification library, for this issue mainly https://github.com/klaftertief/elm-simplify/blob/tail-recursive-array/src/Simplify/RadialDistance.elm.

I applied the open pull requests #396 and #399, but they didn't help.

This test cases crashes in subLengths += a.table[i].table.length (table is undefined) starting at a length of 32^2 - 1*32 + 1.

import Array exposing (append, initialize)
import Graphics.Element exposing (show)

main =
  show <|
    append
      (initialize 1 (always 1))
      (initialize (32^2 - 1*32 + 1) (\i -> i))

It's extracted from this recursive function (which is similar to the one in the linked repo). An interesting thing is that this starts crashing at a length of 32^2 - 2*32 + 1.

import Array exposing (append, empty, get, initialize, length, slice)
import Graphics.Element exposing (show)

run accum array =
  let
    head = get 0 array
    tail = slice 1 (length array) array
  in
    case head of
      Nothing -> accum
      Just x ->
        run
          (append (initialize 1 (always x)) accum)
          tail

main =
  show <|
    run
      empty
      (initialize (32^2 - 2*32 + 1) (\i -> i))

@klaftertief klaftertief changed the title from Array.append causes runtime error on largihs to Array.append causes runtime error on largish arrays Nov 21, 2015

@eeue56

This comment has been minimized.

Show comment
Hide comment
@eeue56

eeue56 Dec 1, 2015

Contributor

I spent a while looking at this problem with @klaftertief and sadly was unable to figure out a solid solution. I'm glad you made it an issue! When I get some time I'll look more into this.

Contributor

eeue56 commented Dec 1, 2015

I spent a while looking at this problem with @klaftertief and sadly was unable to figure out a solid solution. I'm glad you made it an issue! When I get some time I'll look more into this.

@klaftertief

This comment has been minimized.

Show comment
Hide comment
@klaftertief

klaftertief Dec 1, 2015

Thanks @eeue56 for your efforts.

This commit fixes the symptoms of this specific issue, see this test.

There are more Array related bugs/crashes popping up in other test cases, but it's hard to find minimal test cases to have a solid foundation to fix those. I hope I'll find some time to add more minimal failing tests and maybe get a better understanding of the native implementation.

klaftertief commented Dec 1, 2015

Thanks @eeue56 for your efforts.

This commit fixes the symptoms of this specific issue, see this test.

There are more Array related bugs/crashes popping up in other test cases, but it's hard to find minimal test cases to have a solid foundation to fix those. I hope I'll find some time to add more minimal failing tests and maybe get a better understanding of the native implementation.

@dan-tull

This comment has been minimized.

Show comment
Hide comment
@dan-tull

dan-tull Jan 15, 2016

I hit this issue today, though for me the Array.append call that is failing is for arrays of length 963 + 1 and 960 + 2 (both slightly lower bounds than the 993 in the example above).

If it would be useful, I could extract minimal test case for the bug in my scenario.

dan-tull commented Jan 15, 2016

I hit this issue today, though for me the Array.append call that is failing is for arrays of length 963 + 1 and 960 + 2 (both slightly lower bounds than the 993 in the example above).

If it would be useful, I could extract minimal test case for the bug in my scenario.

@eeue56

This comment has been minimized.

Show comment
Hide comment
@eeue56

eeue56 Jan 17, 2016

Contributor

We're working on it

Contributor

eeue56 commented Jan 17, 2016

We're working on it

@evancz evancz referenced this issue Jun 25, 2016

Closed

array problems #649

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jun 25, 2016

Member

Closing in favor of #649 which will track all array issues and progress on a new implementation.

Member

evancz commented Jun 25, 2016

Closing in favor of #649 which will track all array issues and progress on a new implementation.

@evancz evancz closed this Jun 25, 2016

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