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

Race condition in the program during cut / paste #571

Open
lazysegtree opened this issue Jan 25, 2025 · 2 comments
Open

Race condition in the program during cut / paste #571

lazysegtree opened this issue Jan 25, 2025 · 2 comments
Labels
bug Something isn't working performance Issue related to performance of superfile

Comments

@lazysegtree
Copy link
Collaborator

Describe the bug
On a cut and paste operation, there is a race condition that causes the model.copyItems content to reset to old state containing the file that was removed by cut. It causes errors in logs. I think it could lead to some user facing issue as well.

To Reproduce
Steps to reproduce the behavior:

  1. Open spf and perform any cut and paste operation
  2. Check error logs. You would see error like "Clipboard render function get item state error stat <old_file>: no such file or directory\n"

Expected behavior
Clipboard content should get cleaned. Clipboard render function should not be looking for old file.

Screenshots
If applicable, add screenshots to help explain your problem.

Image

( Modified with more logs )
Image

( Here you can see, that Update() function ends before pasteItems() goroutine that it started is finished )
Image

System information (please complete the following information):

  • OS: MacOS
  • Version 14
  • superfile Version 1.1.7.1

I have tried to do some research on this. Spend around 3-4h+ 😅
The paste goroutine call takes time, and sometimes it happens after Update() has been finished and m with original m.copyItems has been returned to bubbletea. Even if m.copyItems would get clear at the end of pasteItems, the next Update() would use a new m with original m.copyItems.

This is not going to be easy to fix. But I will try to take a stab at this after

@lazysegtree lazysegtree added bug Something isn't working performance Issue related to performance of superfile labels Jan 25, 2025
@lazysegtree
Copy link
Collaborator Author

lazysegtree commented Jan 25, 2025

Sometime it causes just "x items left ..." to render in the clipboard panel

Image
Logs

2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_4.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/100M_1.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_1.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_10.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_2.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_3.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_4.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/100M_1.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_1.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_10.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_2.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_3.dat: no such file or directory
2025/01/26 01:29:28 Clipboard render function get item state error
2025/01/26 01:29:28 stat /Users/kuknitin/temp/testf/gen1/10K_4.dat: no such file or directory

@lazysegtree
Copy link
Collaborator Author

Also we sometimes have processes stuck in pending. This could also have something to do with race conditions.
This process stuck sometime happens, and I dont know of the deterministic way of reproducing it yet.

Image

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

No branches or pull requests

1 participant