"fatal error: sync: Unlock of unlocked RWMutex" while adding Dropdown menu to form #35
I am currently writing a terminal based installer for our Linux distribution (Artix Linux) based in cview (actually moved from tview pretty recently) and I am having a very strange panic about a RWMutex trying to be unlocked while it is not locked, the funny part is that there is not a single RWMutex in our custom structures and the unlock is happening when we try to make modifications to a local slice that has absolutely nothing to do with cview. I've spend considerably long time already looking for the possible cause of the issue and I could not find anything, actually while debugging the code jumps to the
Unlock method on the standard library
RWMutex as soon as the execution of the application reach the given point (more details below).
We are following a bit the design on the
presentation let me show you the application code.
The problematic section (a *cview.Page actually) is being initialized in cmd/aim/application.go:46, that is defined in internal/ui/sections/localization.go:241 that as you can see uses the
localizationHandler function defined just below that simply adds pages containing forms to a Pages primitive.
We have a bit of wrapping in there, the
localizationMultiForm data structure embedds a Multiform that is just a thin wrapper around a *cview.Pages that includes a slice of pointers to values of a data structure called MultiFormChoice, the idea behind the whole multiform thing is to present different forms that asks the users to input data or make choices in drop down select boxes (like a typical GUI installation application), the multiform registers the choices the users made on each step in its choices property.
In internal/ui/sections/localization.go:86-93 we add a DropDown to one of the forms, on its selection method we call the
MultiForm's SetChoice that when called will just set a string with the value of the selected choice, the problem is that when the execution reaches line 138 the code just jumps to the aforementioned
Unlock method and you get a
fatal error: sync: Unlock of unlocked RWMutex
I am not sure if we are doing something very wrong in here but I tried to use a global variable in the
localization pacage and when I try to access it using the index operator the same problem occurs.
We also use this wrapper around
cview.Form but that only adds empty boxes around the form to make it to be draw in the center of the screen.
Anyone has any idea of what could be the problem here? We will be eternally grateful to any kind soul that can lend us a hand because this problem has been driving us nuts for a while and we have no clue what can be happening here.
Thank you in advance and continue with the good work.
Thanks for reporting this. I ran into something similar recently and this is helpful in narrowing the cause. I believe this problem was introduced with these recent changes. I'll look into this.
Thank you Trevor, let me know if I can do anything to help you.
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?