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

Sleep Sort in X86-64 Locks Up #4075

Open
rzuckerm opened this issue Dec 7, 2024 · 4 comments
Open

Sleep Sort in X86-64 Locks Up #4075

rzuckerm opened this issue Dec 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@rzuckerm
Copy link
Collaborator

rzuckerm commented Dec 7, 2024

This seems to happen pretty randomly. I can reproduce the issue locally maybe about half the time with this:

poetry run glotter test -l x86-64

Here is an example of the failure. From the failure, it appears that the last entry is not being output. I'm moving archive/x/x86-64/sleep-sort.asm to needs-attention/archive/x/x86-64/sleep-sort.asm.

Copying the original author: @RMarx1456

@rzuckerm rzuckerm added the bug Something isn't working label Dec 7, 2024
@RMarx1456
Copy link
Contributor

It is definitely something to do with the cpu timing differences between the machines and environments. I will work on it when I can again. Thank you.

@RMarx1456
Copy link
Contributor

When I originally made the pull request, it passed all of the test cases, but when mulitiple threads are involved, there's more of a "randomness" to it, so that is likely why it wasn't passing the test cases for that instance.

@RMarx1456
Copy link
Contributor

RMarx1456 commented Dec 7, 2024

My approach might be to spinlock the main thread until the child is done preparing itself (instead of waiting), making the input iterations more strict (whitelisting input characters), and more gracefully terminating the threads (have main send a SIGTERM to the threads).

@RMarx1456
Copy link
Contributor

RMarx1456 commented Dec 7, 2024

        actual = sleep_sort.run(params=in_params)
        actual = actual.replace("[", "").replace("]", "").strip()
>       assert actual == expected
E       AssertionError: assert '1, 2, 3, 4, 4,' == '1, 2, 3, 4, 4, 5'
E         - 1, 2, 3, 4, 4, 5
E         ?               --
E         + 1, 2, 3, 4, 4,

test/generated/test_sleep_sort.py:37: AssertionError
=========================== short test summary info ============================
FAILED test/generated/test_sleep_sort.py::test_sleep_sort_valid[x86-64/sleep-sort.asm-sample input: with duplicate] - AssertionError: assert '1, 2, 3, 4, 4,' == '1, 2, 3, 4, 4, 5'
  - 1, 2, 3, 4, 4, 5
  ?               --
  + 1, 2, 3, 4, 4,
================== 1 failed, 289 passed in 3731.85s (1:02:11) ==================

It's missing the five, so that tells me it's an issue with how the last thread is getting handled, which is the same issue I had on my own machine while first writing this.

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

2 participants