FastAsyncWorldEdit

FastAsyncWorldEdit

152k Downloads

DelegateSemaphore implements synchronized incorrectly

libraryaddict opened this issue ยท 2 comments

commented

Server Implementation

Spigot

Server Version

1.18.1

Describe the bug

https://github.com/IntellectualSites/FastAsyncWorldEdit/blob/main/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/DelegateSemaphore.java

Both acquire() and release() are both synchronized methods, however this fails to account for when two threads are both accessing the same lock.

This is mostly noticeable to us as I often perform some laggy world saving operations.

To Reproduce

Thread $1 calls acquire(), and starts doing some work.
$2 calls acquire(), but has to wait as $1 has the underlying lock.
$1 finishes doing some work, moves to call release()
$1 waits for $2 to finish calling acquire(), because the method is synchronized and release() cannot be called while $2 is calling acquire()

So because $1 has the underlying lock, $2 cannot finish calling acquire(), because $2 has the synchronized lock, $1 cannot call release()

Expected behaviour

$1 calls acquire(), $2 calls acquire(), $1 is not blocked from calling release()

Screenshots / Videos

No response

Error log (if applicable)

https://gist.github.com/ec9b489ef20fe333000a8eb646dd0c7e

Fawe Debugpaste

N/A

Fawe Version

2.0.1-SNAPSHOT-76;e8f72d6

Checklist

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If the issue is still present and can be reproduced, please let the team know. Thank you for your contributions.

commented

Note that this only happens on Spigot