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

Fix for https://github.com/vorburger/MariaDB4j/issues/233 #96

Merged
merged 2 commits into from
Apr 17, 2023

Conversation

cardamon
Copy link
Contributor

Hi,

A fix/mitigation for https://github.com/vorburger/MariaDB4j/issues/233

https://github.com/vorburger/MariaDB4j/issues/233#issuecomment-1131559138 and https://github.com/vorburger/MariaDB4j/issues/233#issuecomment-1258651583 pointed in the right direction, but that seems not to be the actual issue. ExecuteWatchdog#isWatching() calls ExecuteWatchdog#ensureStarted(), which blocks until ExecuteWatchdog#start(Process) is called by the DefaultExecutor in executeInternal(...).

The issue appears to be the opposite - the process completes so quickly that isAlive in ManagedProcess is never set to true because by the time isAlive = watchDog.isWatching() is called, the process already completed.

The or already finished part in the comment

// watchDog.isWatching() blocks if the process never started or already finished,

isn't true I think?

@duttonw
Copy link
Contributor

duttonw commented Feb 14, 2023

Did you need to extend the class? It looks like a good fix that could be inlined with the main class without causing any extra issues.

@cardamon
Copy link
Contributor Author

Agreed, but commons-exec latest release is dated Nov 6, 2014. Although it seems that it recently became active again...

If a new release is in the works than adding something like this over there would indeed be better.

@vorburger
Copy link
Owner

Thanks for the contribution! I'll run this etc. once https://github.com/vorburger/MariaDB4j/issues/680 is fixed...

@vorburger
Copy link
Owner

@cardamon sorry for the long delay. I've run the build on this now, and it fails due to a missing license header in your new class StopCheckExecuteWatchdog... would you like to add that to this PR, so that we can see if it builds cleanly?

@vorburger vorburger self-requested a review March 6, 2023 14:29
@@ -473,7 +473,7 @@ public ManagedProcess waitForExitMaxMsOrDestroy(long maxWaitUntilDestroyTimeout)
}

protected void assertWaitForIsValid() throws ManagedProcessException {
if (!isAlive() && !resultHandler.hasResult()) {
if (!watchDog.isStopped() && !isAlive() && !resultHandler.hasResult()) {
Copy link

Choose a reason for hiding this comment

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

6% of developers fix this issue

THREAD_SAFETY_VIOLATION: Read/Write race. Non-private method ManagedProcess.assertWaitForIsValid() indirectly reads without synchronization from this.isAlive. Potentially races with write in method ManagedProcess.startExecute().
Reporting because another access to the same memory occurs on a background thread, although this access may not.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Copy link
Owner

Choose a reason for hiding this comment

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

#99

Copy link
Contributor

Choose a reason for hiding this comment

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

@vorburger it doesn't seem like this patch introduced this thread safety violation. Can we merge in this patch? It would be a useful improvement even if it preserved the thread safety issue.

Copy link
Owner

Choose a reason for hiding this comment

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

@mosesn thank you very much for having reviewed this; I agree - so (finally, sorry) MERGE this now!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!!

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.

None yet

4 participants