Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Infinite loop in Array.sort #624

Open

Description

  1. Create an arbitrary Array of numbers with length>100
  2. myArray.sort() results in:
  3. Exception: InfiniteLoop
    VM> at sort [as F9_pc84] (node_modules@devicescript\core\src\array.ts:206:13)
    VM> at main [as F0_pc37] (src\main.ts:90:1)

Activity

  1. mmoskal commented on Nov 1, 2023

    @mmoskal
    Contributor

    I suspect it just runs for too long - the algorithm is quadratic - PRs are welcome!

    We limit execution to DEVS_MAX_STEPS (128k) opcodes before you need to yield.

  2. louisvangeldrop commented on Nov 1, 2023

    @louisvangeldrop
    Author

    Is the DEVS_MAX_STEPS a parameter that one can define during runtime?

  3. mmoskal commented on Nov 1, 2023

    @mmoskal
    Contributor

    Not currently.

  4. IvanMtze commented on Dec 22, 2023

    @IvanMtze

    Michał Moskal (@mmoskal) Have you consider using timsort algorithm instead of the current implementation? I believe is what V8 uses. I can work on this if that is a better approach than the code has for now. :)

  5. mmoskal commented on Dec 22, 2023

    @mmoskal
    Contributor

    It would be most welcome!

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions