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

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

问题描述

请参阅MSO问题






有关可能重复的长列表 - C内存分配和超越边界
>开发环境:CentOS 4.7,Kdevelop 3.1.1,gcc 3.4.6



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


  1. Java客户端

  2. C ++共享库JNI包装器。 (我将其称为wrapperlibrary)

  3. 包含业务对象的C ++共享库。 (我将其称为商业库)

当我运行客户端时,我经常遇到错误, c> *** glibc detected *** free():invalid next size(fast):0x080eeef8 *** 。



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

  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 ... 来了。



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

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

然后首先加载商业库(通过全局变量创建日志记录) wrapperlibrary被加载。控制返回到java客户端,并且在控制台上打印语句wrapper library loaded。之后,有一个调用
到本地方法。但是控件从来没有达到这个本地方法的实现。而在之前,错误 *** glibc ... 再次出现。另外,如果我在本地方法调用之前插入另一个java类的静态方法调用,如

  static 
{
System.Load(/ root / Desktop / libs / wrapperlibrary);
System.out.println(wrapper library loaded);
System.out.println(Try.temp()); //其中temp是Try类的静态方法,它返回一个字符串。

本地方法调用;

-
-
}



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

解决方案

它可能是Java本身链接到不同的glibc比你的库或者库是不同的链接到不同的glibcs​​。 >
同时检查其中一个库是否与glibc的调试版本链接(使用C ++运行时库在Windows上的问题)。
尝试将您的库静态地与glibc链接,或者为了排除将封装器和业务库静态链接到一个库中的可能性。


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


Developer environment: CentOS 4.7, Kdevelop 3.1.1, gcc 3.4.6

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

  1. Java client
  2. C++ shared library which acts as a JNI wrapper. (I will call it "wrapperlibrary")
  3. C++ shared library containing business objects. (I will call it "businesslibrary")

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.

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");
}

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

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");
}

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;

 --
 --
}

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?

解决方案

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天全站免登陆