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

Process>>resume seems to cancel Semaphore>>wait, violating process synchronization guarantees #10669

Open
martinmcclure opened this issue Dec 18, 2021 · 2 comments

Comments

@martinmcclure
Copy link
Contributor

Bug description
A Process performing a wait on a Semaphore with no excess signals should wait until that semaphore is signaled by some other Process, or until the waiting Process is terminated.
Instead, it looks like suspending and resuming the Process lets it "get out of jail free" and proceed past the wait it's in.
This is a Major violation of inter-process synchronization safety.

To Reproduce
Time millisecondsToRun: [
| proc sema1 sema2 |
sema1 := Semaphore new.
sema2 := Semaphore new.
proc := [
sema2 wait.
sema1 signal ] newProcess.
proc priority: Processor activeProcess priority - 1.
proc resume.
1 seconds wait.
proc suspend.
proc resume.
sema1 wait ]

Expected behavior
Hangs forever.

Actual behavior
Answers a number of milliseconds slightly over 1000.

Version information:

  • OS: Linux
  • Version: Gentoo stable
  • Pharo Version: 9, build 1573

Expected development cost
Unknown. Much of the behavior is in primitives, so it could well be a VM issue.

@guillep
Copy link
Member

guillep commented Dec 20, 2021

Yes, I realized this some time ago too.

I wonder if we cannot just do it on the library side. Making the primitive resume into a method primitiveResume and then resume check before if it can resume. Doing it on the library side gives the opportunity of using some polymorphism on the process list ;)

@martinmcclure
Copy link
Contributor Author

I haven't looked at the code in detail (and the VM code not at all) but am generally in favor of moving functionality into the image, and having only the minimum in the VM for necessary safety/critical sections.

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

2 participants