需要解释为什么会发生EXCEPTION_ACCESS_VIOLATION [英] need explanation on why does EXCEPTION_ACCESS_VIOLATION occur

查看:69
本文介绍了需要解释为什么会发生EXCEPTION_ACCESS_VIOLATION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我将要显示的错误无法通过代码解决.我只是想知道它的原因和原因,而且我也知道它是由于JVM试图访问另一个程序的地址空间所致.

Hi I know that this error which I'm going to show can't be fixed through code. I just want to know why and how is it caused and I also know its due to JVM trying to access address space of another program.

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

  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6dcd422a, pid=4024, tid=3900

 JRE version: 6.0_14-b08
 Java VM: Java HotSpot(TM) Server VM (14.0-b16 mixed mode windows-x86 )
 Problematic frame:
 V  [jvm.dll+0x17422a]

An error report file with more information is saved as:
C:\PServer\server\bin\hs_err_pid4024.log

If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp

推荐答案

塔南鲍姆(Tanenbaum)的现代操作系统"这本书,可在此处在线获取:

The book "modern operating systems" from Tanenbaum, which is available online here:

http://lovingod.host.sk/tanenbaum/Unix-Linux- Windows.html

深入讨论主题. (第4章在内存管理"中,第4.8章在内存分段"中).简短版本:

Covers the topic in depth. (Chapter 4 is in Memory Management and Chapter 4.8 is on Memory segmentation). The short version:

如果您PC上的多个程序可以访问彼此的内存,那将是非常糟糕的.实际上,即使在一个程序中,甚至在一个线程中,您都具有多个不能相互影响的内存区域.通常,一个进程至少有一个称为堆栈"的内存区域和一个称为堆"的区域(通常每个进程有一个堆+每个线程一个堆栈.可能有更多的段,但这取决于实现,并且它不依赖于实现重要的是这里的解释).在堆栈上,将保存诸如函数的参数和局部变量之类的内容.堆上保存的变量的大小和生存期无法由编译器在编译时确定(在Java中,您使用"new" -Operator进行的所有操作都将在此确定).

It would be very bad if several programs on your PC could access each other's memory. Actually even within one program, even in one thread you have multiple areas of memory that must not influence one other. Usually a process has at least one memory area called the "stack" and one area called the "heap" (commonly every process has one heap + one stack per thread. There MAY be more segments, but this is implementation dependent and it does not matter for the explanation here). On the stack things like you function's arguments and your local variables are saved. On the heap are variables saved that's size and lifetime cannot be determined by the compiler at compile time (that would be in Java everything that you use the "new"-Operator on. Example:

public void bar(String hi, int myInt)
{
  String foo = new String("foobar");
}

在此示例中,

是两个String对象:(由"foo"和"hi"引用).这两个对象都在堆上(您知道这一点,因为在某些时候,两个字符串都是使用"new"分配的.在此示例中,堆栈上有3个值.这将是"myInt","hi"和重要的是要认识到"hi"和"foo"并不真正直接包含字符串,而是包含一些ID来告诉它们在堆中可以找到该字符串.(这并不容易.解释使用Java的原因,因为Java抽象了很多.在C中,"hi"和"foo"将是一个Pointer,实际上它只是一个整数,表示存储实际值的堆中的地址.

in this example are two String objects: (referenced by "foo" and "hi"). Both these objects are on the heap (you know this, because at some point both Strings were allocated using "new". And in this example 3 values are on the stack. This would be the value of "myInt", "hi" and "foo". It is important to realize that "hi" and "foo" don't really contain Strings directly, but instead they contain some id that tells them were on the heap they can find the String. (This is not as easy to explain using java because java abstracts a lot. In C "hi" and "foo" would be a Pointer which is actually just an integer which represents the address in the heap where the actual value is stored).

您可能会问自己为什么仍然存在堆栈和堆.为什么不将所有内容放在同一位置.不幸的是,解释超出了此答案的范围.阅读我链接的书;-).简短的版本是对堆栈和堆进行不同的管理,并且出于优化的原因进行了分离.

You might ask yourself why there is a stack and a heap anyway. Why not put everything in the same place. Explaining that unfortunately exceeds the scope of this answer. Read the book I linked ;-). The short version is that stack and heap are differently managed and the separation is done for reasons of optimization.

堆栈和堆的大小是有限的. (在Linux上执行ulimit -a,您将获得一个列表,其中包括数据段大小"(堆)和堆栈大小"(是...堆栈:-).).

The size of stack and heap are limited. (On Linux execute ulimit -a and you'll get a list including "data seg size" (heap) and "stack size" (yeah... stack :-)).).

堆栈是不断增长的东西.就像一个数组,如果您添加越来越多的数据,它将变得越来越大.最终,您用完了空间.在这种情况下,您可能最终在不再属于您的存储区中进行写入.那将是非常糟糕的.因此,操作系统会注意到这一点,并在发生这种情况时将其停止.在Linux上,您会遇到"Segmenation错误";在Windows上,您会遇到访问冲突".

The stack is something that just grows. Like an array that gets bigger and bigger if you append more and more data. Eventually you run out of space. In this case you may end up writing in the memory area that does not belong to you anymore. And that would be extremely bad. So the operating systems notices that and stops the program if that happens. On Linux you get a "Segmenation fault" and on Windows you get an "Access violation".

在其他语言(如C语言)中,您需要手动管理内存.微小的错误很容易导致您意外地写入一些不属于您的空间.在Java中,您具有自动内存管理"功能,这意味着JVM会为您完成所有这一切.您无需在意,开发人员会从肩膀上承担很多负担(通常是这样.我敢打赌,那里的人会不同意负载"部分;-).这意味着/应该/不可能用java产生分段错误.不幸的是,JVM并不完美.有时它有错误和错误.然后你得到你所得到的.

In other languages like in C, you need to manage your memory manually. A tiny error can easily cause you to accidentally write into some space that does not belong to you. In Java you have "automatic memory management" which means that the JVM does all this for you. You don't need to care and that takes loads from your shoulders as a developer (it usually does. I bet there are people out there who would disagree about the "loads" part ;-)). This means that it /should/ be impossible to produce segmentation faults with java. Unfortunatelly the JVM is not perfect. Sometimes it has bugs and screws up. And then you get what you got.

这篇关于需要解释为什么会发生EXCEPTION_ACCESS_VIOLATION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆