简体   繁体   English

Java应用程序在Eclipse中运行,随机出现“致命错误”

[英]Java application running in eclipse, random “fatal errors”

I have written a short application that converts files from their raw data to XML (ECGs). 我编写了一个简短的应用程序,将文件从其原始数据转换为XML(ECG)。 I have about 350000 files to convert, and the convertion itself is done via a library that I got from the manufacturer of the ECG devices. 我大约有350000个文件要转换,转换本身是通过我从ECG设备制造商那里获得的库完成的。 To make use of multiple processors and cores in the machine I'm using to do the convertion I wrote a "wrapper application" that creates a pool of threads, which is then used to do the convertion in separate threads. 为了在我用来进行转换的机器中利用多个处理器和内核,我编写了一个“包装器应用程序”,该程序创建了一个线程池,然后将其用于在单独的线程中进行转换。 It works somewhat ok, but unfortunately I do get random errors causing the whole application to stop (85k files have been converted over the past 3-4 days and I have had four of those errors): 它工作正常,但不幸的是,我确实收到随机错误,导致整个应用程序停止运行(过去3-4天转换了85k个文件,而我遇到了其中四个错误):

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x71160a6c, pid=1468, tid=1396

JRE version: Java(TM) SE Runtime Environment (8.0_20-b26) (build 1.8.0_20-b26)
Java VM: Java HotSpot(TM) Client VM (25.20-b23 mixed mode windows-x86 )
Problematic frame:
C  [msvcr100.dll+0x10a6c]

I would suspect that it's the library that I'm using that causes these, so I don't think I can do all that much to fix it. 我会怀疑是由我使用的库导致了这些,所以我认为我无法做很多事情来修复它。 If that error happens, I run then program and let it start where it left off before crashing. 如果发生该错误,我将运行程序,然后使其从崩溃之前的中断处开始。 Right now I have to do that manually but was hoping that there is some way to let Eclipse restart the program (with an argument of the filename where it should start). 现在,我必须手动执行此操作,但希望有某种方法可以让Eclipse重新启动程序(使用应在文件名处启动的文件名)。 Does anyone know if there is some way to do that? 有谁知道是否有某种方法可以做到这一点?

Thanks! 谢谢!

It is not entirely clear, but I think you are saying that you have a 3rd party Java library (with a native code component) that you are running within one JVM using multiple threads. 尚不清楚,但我想您是说您有一个第三方Java库(带有本机代码组件),该库正在一个JVM中使用多个线程运行。

If so, I suspect that the problem is that the native part of the 3rd-party application is not properly multi-threaded, and that is the root cause of the crashes. 如果是这样,我怀疑问题出在第三方应用程序的本机部分没有正确的多线程, 就是崩溃的根本原因。 (I don't expect that you want to track down the cause of the problem ...) (我不希望您想找出问题的原因...)

Instead of using one JVM with multiple converter threads, use multiple JVMs each with a single converter thread. 与其将一个JVM与多个转换器线程一起使用,不如将多个JVM与一个转换器线程一起使用。 You can spread the conversions across the JVMs either by partitioning the work statically, or by some form of queueing mechanism. 您可以通过静态划分工作或通过某种形式的排队机制来在JVM之间分布转换。

Or ... you could modify your existing wrapper so that the threads launched the converter in a separate JVMs using ProcessBuilder. 或者...您可以修改现有的包装器,以便线程使用ProcessBuilder在单独的JVM中启动转换器。 If a converter JVM crashes, the wrapper thread that launched it could just launch it again. 如果转换器JVM崩溃,则启动它的包装线程可以再次启动它。 Alternatively, it could just make a note of the failed conversion and move onto the next one. 或者,它可以仅记录失败的转换并转到下一个转换。 (You need to be a bit careful with retrying, in case it is something about the file that you are converting that is triggering the JVM crash.) (如果要转换的文件触发了JVM崩溃,则在重试时要谨慎一些。)


For the record, I don't know of an existing "off the shelf" solution. 作为记录,我不知道现有的“现成”解决方案。

It seems that you are using the x86 (32-bit) version of Java. 看来您正在使用Java的x86(32位)版本。 Maybe you could try it with the x64 (64-bit) version. 也许您可以尝试使用x64(64位)版本。 That has sometimes worked for me in the past. 过去,这有时对我有用。

The problem seems to be in the native library, but maybe if you try it with 64-bit Java, it will use a 64-bit version of the native library? 问题似乎出在本机库中,但也许如果您尝试使用64位Java,它将使用本机库的64位版本吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM