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

MT hardening FileInfoReader #568 #569

Closed
wants to merge 2 commits into from

Conversation

jukzi
Copy link
Contributor

@jukzi jukzi commented Nov 18, 2024

The value of the barrier (true/false) was never read. It was only checked for !=null. The value had been read in waitOnSelf() without any multithreading semantics like synchronize/volatile. Instead now we use a thread safe AtomicBoolean. The synchronization blocks are still used for wait()/notifyAll()

#568

EcljpseB0T and others added 2 commits November 18, 2024 15:55
The value of the barrier (true/false) was never read. It was only
checked for !=null. The value had been read in waitOnSelf() without any
multithreading semantics like synchronize/volatile.
Instead now we use a thread safe AtomicBoolean. The synchronization
blocks are still used for wait()/notifyAll()

eclipse-equinox#568
@eclipse-equinox-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From cb70abf0a514d9f4308026a0159887f6c63f375c Mon Sep 17 00:00:00 2001
From: Eclipse Equinox Bot <[email protected]>
Date: Mon, 18 Nov 2024 14:59:31 +0000
Subject: [PATCH] Version bump(s) for 4.34 stream


diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
index 6e526b259..453d5aafa 100644
--- a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.equinox.p2.transport.ecf
-Bundle-Version: 1.4.300.qualifier
+Bundle-Version: 1.4.400.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-17
 Require-Bundle: org.eclipse.ecf;bundle-version="3.1.0",
  org.eclipse.ecf.filetransfer;bundle-version="4.0.0",
-- 
2.47.0

Further information are available in Common Build Issues - Missing version increments.

Copy link
Member

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of the group of Atomic primitives is that they don't require any synchronization at all (and some tools will complain that this is code-smell).

Why not use a real barrier (e.g. CountDownLatch) here that do not require syncronization.

*/
private void waitOnSelf() {
schedule();
while (barrier[0] == null) {
while (!barrierReached.get()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must confess that I can't get what is the purpose of this loop... if I schedule a job once how can I join it more than once?

@merks any clue whats the purpose of this?

@jukzi
Copy link
Contributor Author

jukzi commented Nov 18, 2024

CountDownLatch can not be reset. CyclicBarrier can be reset but not read/mixed with the wait loop that askes for cancel. If you find any better solution please do. Meanwhile this could improve the situation.

synchronized (barrier) {
while (barrier[0] == null) {
synchronized (barrierReached) {
while (!barrierReached.get()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes behavior before any value TRUE/FALSE would have ended the loop now it loops forever if set to false.

@laeubi
Copy link
Member

laeubi commented Nov 18, 2024

CountDownLatch can not be reset.

The true/false value is actually never evaluated in the code of question, the only purpose seem to be to know if it has ended "normal" or for "unkown" reasons (maybe debugging?)

@laeubi
Copy link
Member

laeubi commented Nov 18, 2024

If you find any better solution please do. Meanwhile this could improve the situation.

Please add a testcase to prove it

  • actually works as before
  • actually fix the bug described

from a code-review point of view this changes to much here to make it save.

e.g. my proposed absolute minimal change (so it has a chance to get into RC phase) would be to refactor the check in the while into a method that synchronize on the array. That's not nice but if it is a thread-visibility problem would fix the problem in a way that can confidently be reviewed.

Copy link

Test Results

  375 files  ±0    375 suites  ±0   43m 39s ⏱️ + 1m 11s
1 904 tests ±0  1 901 ✅ ±0  3 💤 ±0  0 ❌ ±0 
6 712 runs  ±0  6 703 ✅ ±0  9 💤 ±0  0 ❌ ±0 

Results for commit b880a5f. ± Comparison against base commit 65348d6.

@merks
Copy link
Contributor

merks commented Nov 18, 2024

We're in the RC2 phase so nothing will get done for this release.

I'm really uncomfortable changing something here simply because we theorize that it might be broken with no reproducible way to test that we've actually fixed what we think is the problem rather than simply changed the behavior a bit and hoping for the best that this somehow helps something. How many times has even the most simple, innocent change broken something? I've lost count. But that's just my opinion and perhaps it's simply paranoia...

@jukzi
Copy link
Contributor Author

jukzi commented Nov 18, 2024

I don't want this for any RC but M1. Simply adding a synchronize around an endless loop would harm more then help: The only use of synchronize in that class is the notify/wait mechanism - that does not exist in waitOnSelf().

@laeubi
Copy link
Member

laeubi commented Nov 18, 2024

Simply adding a synchronize around an endless loop would harm more then help:

I didn't suggested to put it around the loop ...

The only use of synchronize in that class is the notify/wait mechanism - that does not exist in waitOnSelf().

Then please fix up the PR/Commit message this PR seem to do something different then.

Maybe it would be better to have two PRs for two things as well.

@jukzi
Copy link
Contributor Author

jukzi commented Dec 12, 2024

Maybe it would be better to have two PRs for two things as well.

@laeubi please provide such.

@jukzi jukzi closed this Dec 12, 2024
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.

5 participants