Menu

#23 JVM crashes upon calling initSevenZipFromPlatformJAR

open
5
2017-01-19
2017-01-03
No

Hi,

First of all, the issue i am going to describe is happening in the latest version 9.20 also.

I have a linux service which when starting is trying to initialize 7zipbinding from jar.
The code snippet:

public class Extractor7ZipHelper  {
    private static final Logger logger = LoggerFactory.getLogger(Extractor7ZipHelper.class);

    enum SingleInstance {
        INSTANCE();

        @Value("${common.internal_file_sharing_path}")
        private String sevenZipTempDir;

        private final Logger logger = LoggerFactory.getLogger(Extractor7ZipHelper.class);

        private SingleInstance() {
            final boolean loadedFromjar = loadLibraryFromJar();
            if (!loadedFromjar){
                return;
            }
            logger.info("7Zip initialized successfully!");
        }

        private boolean loadLibraryFromJar() {
            logger.info("Trying to initialize 7Zip with JAR built-in native library");
            try {
                SevenZip.initSevenZipFromPlatformJAR(sevenZipTempDir);
            } catch (Exception e) {
                logger.error("Was not able to pre-initialize 7zip", e);
                return false;
            }
            return true;
        }
    }

    static {
        //singleton initialization by reference.
        logger.info("Helper loaded: " + SingleInstance.INSTANCE.getClass());
    }
}

There are several services which all use 7zip. some of the services are starting successfully while others are crashing and producing the crash dump file i have attached.
restarting the services doesnt help and only after i am rebooting the server the services are able to start successfully.

please assist.

1 Attachments

Discussion

  • Boris Brodski

    Boris Brodski - 2017-01-11

    Hello Dani,

    thank you for the bug report.

    Did you find out, which services are crashing and which are not?
    (depending on some characteristics)

    Can it be, that you are mixing 32 and 64 bit java?
    If so, try the "all-platform" or "all-linux" versions.

    Can you test your code with older 7-Zip-JBinding version?

    Cheers,
    Boris

     
  • Dani Gelmanovich

    Hi Boris,

    i knew from the beginning which services crashed, but its not always deterministic: after reboot of the server it is possible that same services will crash, that all services will start successfully or some other services will crash this time. Didnt find special characteristics to distinguish between the services (all of them are Spring applications)

    we have a single build server with java 8 only (1.8u20), but anyway we are using the all-platform version.

    I will try to test the code in older version. Do you have a specific version that you would like me to test?

    Best regards,
    Dani

     
  • Boris Brodski

    Boris Brodski - 2017-01-11

    Hi Dani,

    please, try the previous version (4.65-1.06rc-extr-only). This may break your code, but we are currently interested only in the initialization, so this shouldn't be a big deal.

    I have another idea: which application server do you use?
    It may be the classloader issue. You may be loading sevenzipjbinding.jar multiple times with different classloaders. This is not really supported yet. If this is the case, please, put the 7-Zip-JBinding libraries to some public-lib directory of the application server, so that it gets loaded with the global classloader.

    Best regards,
    Boris

     
  • Dani Gelmanovich

    Hi Boris,

    You probably missed it but i mentioned that i have tried both version 4.65-1.06rc-extr-only and 9.20.
    I am using Spring boot application server.
    Your idea sounds interesting, i will give it a shot!
    I will update with the results..

    Dani

     
  • Dani Gelmanovich

    Hi Boris,

    After some overview of our code we decided that its not a classloader issue.
    However, you gave us a lead to check concurerncy issues between multiple processes during initialization. We think we identified the issue which - all the processes are using the same temp folder so during initialization the files are getting extracted and overriden to the same place by some processes while other processes are trying to read the extracted content.
    After refactoring it looks like the issue has been solved, but i would give it a few weeks to make sure that this solution is the right one.

    Anyway thanks a lot!

    Best regards,
    Dani

     
  • Boris Brodski

    Boris Brodski - 2017-01-19

    Hi Dani,

    thank you very much for the feedback. Do you have mutiple java processes or under "other processes" you just meen other threads?

    Kind regards,
    Boris

     
  • Dani Gelmanovich

    Yes, multiple java processes which are using the same sevenzip initialization infrastructure.

     

Log in to post a comment.