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

Infinite loop in Array.sort #624

Open
louisvangeldrop opened this issue Sep 17, 2023 · 5 comments
Open

Infinite loop in Array.sort #624

louisvangeldrop opened this issue Sep 17, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@louisvangeldrop
Copy link

  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)
@louisvangeldrop louisvangeldrop added the bug Something isn't working label Sep 17, 2023
@mmoskal
Copy link
Member

mmoskal commented Nov 1, 2023

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.

@louisvangeldrop
Copy link
Author

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

@mmoskal
Copy link
Member

mmoskal commented Nov 1, 2023

Not currently.

@IvanMtze
Copy link

@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. :)

@mmoskal
Copy link
Member

mmoskal commented Dec 22, 2023

It would be most welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants