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

JVM crash when closing MediaDriver after failed close of Aeron client. #607

Closed
aptdevel opened this issue Jan 3, 2019 · 1 comment
Closed

Comments

@aptdevel
Copy link

aptdevel commented Jan 3, 2019

Hello,

I am experiencing a JVM crash when closing the MediaDriver, which appears to be related to a previous attempt to close the Aeron client that failed due to thread interruption.

I am using Aeron 1.13.0 with Oracle JDK 1.8.0_191 on Linux.

Here is a short example that crashes:

import io.aeron.Aeron;
import io.aeron.Publication;
import io.aeron.driver.MediaDriver;

public class AeronCrashOnDriverCloseAfterInterruptBeforePublisherClose {
    public static void main(String[] args) {
        final MediaDriver.Context driverCtx = new MediaDriver.Context();
        // For cleanliness; not relevant.
        driverCtx.warnIfDirectoryExists(false).dirDeleteOnStart(true);
        
        final Aeron.Context clientCtx = new Aeron.Context();
        
        try (MediaDriver driver = MediaDriver.launch(driverCtx);
            Aeron client = Aeron.connect(clientCtx);
            Publication pub = client.addPublication("aeron:ipc", 42))
        {
            // Comment this out and program exits normally.
            Thread.currentThread().interrupt();
        }
    }
}

The Publication#close() doesn't need to fail for the crash to happen. The determining factor seems to be whether the Aeron#close() was interrupted. Here is a slightly more verbose example with a successful Publication close:

import io.aeron.Aeron;
import io.aeron.Publication;
import io.aeron.driver.MediaDriver;

public class AeronCrashOnDriverCloseAfterInterruptBeforeClientClose {
    public static void main(String[] args) {
        final MediaDriver.Context driverCtx = new MediaDriver.Context();
        // For cleanliness; not relevant.
        driverCtx.warnIfDirectoryExists(false).dirDeleteOnStart(true);
        
        final Aeron.Context clientCtx = new Aeron.Context();
        
        final MediaDriver driver = MediaDriver.launch(driverCtx);
        try {
            final Aeron client = Aeron.connect(clientCtx);
            try {
                // Need to add a Publication, or the crash will not happen.
                final Publication pub = client.addPublication("aeron:ipc", 42);
                pub.close();
                
                // Comment this out and program exits normally.
                Thread.currentThread().interrupt();
            } finally {
                // This will throw AeronException because of interrupt flag.
                // (Publication would sneaky-throw InterruptedException.)
                client.close();
            }
        } finally {
            // This will cause JVM to crash if the Aeron#close() failed.
            driver.close();
        }
    }
}

I can provide an hs_err log if that helps.

Thank you.

mjpt777 added a commit that referenced this issue Jan 4, 2019
@mjpt777 mjpt777 closed this as completed Jan 4, 2019
@aptdevel
Copy link
Author

aptdevel commented Jan 5, 2019

Thank you for the quick turnaround.

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

No branches or pull requests

2 participants