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

Update table.go - Fixed a bug with concurrent access zu the maps for … #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JanVaya
Copy link
Owner

@JanVaya JanVaya commented Jul 25, 2024

…columns width and row heights

Description:

If a UpdateCell-func calls table.SetRowHeight() to adjust the height of the current row two problems arise.

  1. This enforces a table.Refresh() which in turn executes a call to UpdateCell and could produce an infinite loop until the stack is exhausted. This can be prevented by a simple variable lock in the UpdateCell-func that avoids setting the RowHeight twice.

  2. If that is fixed and a large table is scrolled it will run into a “concurrent map write” fatal error. This is because the ongoing updates run in parallel to UpdateCell-Calls and at some time a read of the map will happen in parallel to a write of the map.

I have fixed this problem, at least for my tests, by introducing a mutex that saveguards all accesses to the map. I have not savguarded the other maps, as they are no generating any errors. Hope this helps and would be glad to see this in the main branch.

Fixes fyne-io#5007

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

…columns width and row heights

If a UpdateCell-func calls table.SetRowHeight() to adjust the height of the current row two problems arise.

1.	This enforces a table.Refresh() which in turn executes a call to UpdateCell and could produce an infinite loop until the stack is exhausted. This can be prevented by a simple variable lock in the UpdateCell-func that avoids setting the RowHeight twice.

2.	If that is fixed and a large table is scrolled it will run into a “concurrent map write” fatal error. This is because the ongoing updates run in parallel to UpdateCell-Calls and at some time a read of the map will happen in parallel to a write of the map.

I have fixed this problem, at least for my tests, by introducing a mutex that saveguards all accesses to the map. I have not savguarded the other maps, as they are no generating any errors.
Hope this helps and would be glad to see this in the main branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stack overflow when calling SetRowHeight in table UpdateCell callback
1 participant