面临错误“*** glibc detected *** free(): invalid next size (fast)" [英] Facing an error "*** glibc detected *** free(): invalid next size (fast)"

查看:16
本文介绍了面临错误“*** glibc detected *** free(): invalid next size (fast)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅 MSO 问题 一长串可能的重复项——C 内存分配和超出界限,了解密切相关的问题.

Please see MSO question A long list of possible duplicates — C memory allocation and overrunning bounds for information about closely related questions.

开发环境:CentOS 4.7、Kdevelop 3.1.1、gcc 3.4.6

Developer environment: CentOS 4.7, Kdevelop 3.1.1, gcc 3.4.6

我运行一个 Java 测试客户端,它使用 JNI 加载一个 C++ 共享库.我的应用程序中有三个组件,

I run a Java test client that loads a C++ shared library using JNI. There are three components in my application,

  1. Java 客户端
  2. 作为 JNI 包装器的 C++ 共享库.(我将其称为包装库")
  3. 包含业务对象的 C++ 共享库.(我称之为商业图书馆")

当我运行客户端时,我经常遇到一个错误,即 *** glibc detected *** free(): invalid next size (fast): 0x080eeef8 ***.此错误出现大约 10 到 11 次,然后应用程序运行.

When I run the client I face an error very frequently which is, *** glibc detected *** free(): invalid next size (fast): 0x080eeef8 ***. This error comes for around 10 - 11 times and then the application runs.

在我的 Java 客户端中,我首先将所需的 C++ 库加载到静态 ctor 中,如下所示,

In my Java client, I first load the required C++ libraries in a static ctor as follows,

static
{
System.Load("/root/Desktop/libs/businesslibrary");
System.out.println("business library loaded");
System.Load("/root/Desktop/libs/wrapperlibrary");
System.out.println("wrapper library loaded");
}

业务库已加载"语句打印在控制台上,但之后出现错误 *** glibc....

The statement "business library loaded" gets printed on the console but after it the error *** glibc... comes.

在wrapperlibrary的项目设置中,businesslibrary被指定为依赖库.所以,即使我省略了加载 businesslibrary 的调用而只写,

In the project settings of wrapperlibrary, the businesslibrary is specified as a dependant library. So, even if I omit the call to load businesslibrary and just write,

static
{
System.Load("/root/Desktop/libs/wrapperlibrary");
System.out.println("wrapper library loaded");
}

然后首先加载businesslibrary(通过全局变量创建日志查看),然后加载wrapperlibrary.控件返回 java 客户端,并在控制台上打印语句已加载包装库".在此之后有一个电话到本地方法.但是控件永远不会到达这个本机方法的实现.而在此之前,错误 *** glibc... 再次出现.此外,如果我在本地方法调用之前插入对另一个 java 类的静态方法的调用,例如,

then firstly the businesslibrary gets loaded(seen through global variable creation logging) and then the wrapperlibrary gets loaded. The control returns back to java client and the statement "wrapper library loaded" is printed on console. After this there is a call to native method. But the control never reaches this native method's implementation. Rather before that the error *** glibc... again comes. Also if I insert a call to static method of another java class before native method call such as,

static
{
 System.Load("/root/Desktop/libs/wrapperlibrary");
 System.out.println("wrapper library loaded");
 System.out.println(Try.temp()); //where temp is a static method of Try class which returns a string.

 native method call;

 --
 --
}

然后 Try.temp() 的输出永远不会被打印出来.

then output of Try.temp() never gets printed.

这两种方法中出现问题的可能原因是什么?我应该如何处理?

What could be the possible reasons for the problem in both these approaches and how should I proceed?

推荐答案

可能是 Java 本身链接到了与您的库不同的 glibc,或者这些库链接到不同/不同的 glibcs​​.
还要检查其中一个库是否链接到 glibc 的调试版本(使用 C++ 运行时库在 Windows 上解决该问题).尝试将您的库静态链接到 glibc,或者为了排除将您的包装器和业务库静态链接到一个库的可能性.

It could be that Java itself is linked against a different glibc than your libraries or that the libraries are linked differently/to different glibcs.
Also check if one of the libraries is linking against a debug version of the glibc (hat that problem on windows with the C++ runtime lib). Try linking your libraries staticly against the glibc, or for the sake of excluding possibilities linking your wrapper and business libs staticly into one library.

这篇关于面临错误“*** glibc detected *** free(): invalid next size (fast)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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