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

ObservableValueHolder>>value: lock instVar can get stuck to true #16858

Closed
ericwinger opened this issue Jul 4, 2024 · 2 comments
Closed

ObservableValueHolder>>value: lock instVar can get stuck to true #16858

ericwinger opened this issue Jul 4, 2024 · 2 comments
Assignees

Comments

@ericwinger
Copy link

Bug description
Occasionally, I see a Spec2 list seem to get "disconnected" and the rest of the gui wouldn't update after a selection change.

I chased the problem down and eventually I observed that SpMultipleSelectionMode>>selectIndexes: wasn't honoring the subscription blocks in the selectedIndexes ObservableSlot. Turns out that the lock inst var in the ObservableValueHolder would get stuck to true. If lock gets stuck to true, the gui won't update anymore. The culprit may be that there is a tiny window where if a process in ObservableValueHolder>>#value: is terminated after lock is set to true, but before the ensure block is invoked, lock will forever be true. See code below.

value: anObject
	"Handle circular references as explained in the class comment"
	lock ifTrue: [ ^ self ].

	lock := true.   <<<<<<<< If the process is terminated after lock is set to true, but before the block is invoked, lock will forever be true. 

	[ | oldValue |
	oldValue := value.
	value := anObject.
	self valueChanged: oldValue ]
		ensure: [ lock := false ]

Some potential fixes:

  1. Move "lock := true" code inside the ensure block.
  2. Wrap the "lock := true" in another ensure block which runs the original ensure block.
  3. Possibly use a #valueUninterruptably (but that could have unintended side effects)

I'm experimenting with #1 and #2 solutions to see if they eliminate the problem.

To Reproduce
Hard to reproduce, but you can try killing processes that are changing slot values.

Expected behavior
Don't let lock get stuck in true so subscription blocks will always run

Screenshots
None

Version information:
Reproduced in Pharo 11.
Code is identical in Pharo 12.
Pharo 12.0.0
Build information: Pharo-12.0.0+SNAPSHOT.build.1516.sha.25ecf718d4a363b275862b4a093b1a240ec7e8d2 (64 Bit)

Expected development cost
Shouldn't be too hard to fix if my analysis is correct.

Additional context
Very hard to reproduce this problem but was impacting user severely.

@MarcusDenker MarcusDenker self-assigned this Jul 5, 2024
@Ducasse
Copy link
Member

Ducasse commented Jul 6, 2024

THANKS a lot for your findings.
I would explain why alain mentions problems with observeSlot.
@plantec
@tesonep
@MarcusDenker

@Ducasse
Copy link
Member

Ducasse commented Jul 6, 2024

I do not understand what the assignment is not part of the ensure.

ericwinger added a commit to GemTalk/JadeiteForPharo that referenced this issue Jul 8, 2024
ObservableValueHolder had a window where lock inst var could get stuck in `true` preventing updates. Not sure this is the best fix - still testing. May be able to put `lock := true` inside inner ensure block but saw some weird behavior when I tried that so went this way. 
pharo-project/pharo#16858
MarcusDenker added a commit that referenced this issue Sep 23, 2024
…ue-lock-instVar-can-get-stuck-to-true

Fix #16858 moving the assignment inside the ensure block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants