Full stack traces:
After all I was able to work around this problem, EVP_CipherUpdate (or jni ReleaseByteArrayElements) sometimes overflow the output buffer causing the heap corruption, nothing in my code was wrong and also it was not a problem with the caller as replacing EVP_CipherUpdate with a memcpy call with the same parameters worked as expected and there was no heap corruption.
So the solution was adding some extra length to the output buffer sent to nativeUpdate and the error was gone.
I have made the full working version of the library for others to use at:https://github.com/frisco82/conceal
本文地址:IT屋 » Heap Corruption - SEGV_MAPERR in Android Native code
我试图创建流AES加密一个小型图书馆,我开始根据在Facebook上隐匿的项目我的工作( HTTPS ://github.com/facebook/conceal ),只是改变了一些东西,提高各地土特产包装,支持密码与填充
这是工作,它可以破译文件没有问题,但我得到随机的堆内存当我和大数据流工作,很多时间调试后,我一直无法找到错误。
下面是我的code:结果
https://gist.github.com/frisco82/9782725
我试图找到内存分配或免费的问题,但几乎没有的malloc或免费的,JNI调用应该是安全的,同样也适用于OpenSSL的那些(我编我自己却难掩提供的人也会失败)
CheckJni不会警告任何东西,虽然上下文处理有点开箱似乎没有它不坏了(确实的Android conscrypt似乎使用类似的东西)。
此外,如果有人可以点我到Android原生AES多步(多更新调用)库,我会切换到这一点,忘记这一点。
的误差变化从时间到时间,但它通常是类似于他
10月3日至26日:33:02.065:A / dalvikvm(2475):@@@ ABORTING:DALVIK:堆内存损坏IN mspace_malloc地址=为0x0
10月3日至26日:33:02.065:A / libc的(2475):在0xdeadbaad致命信号11(SIGSEGV)(code = 1),螺纹2494(AsyncTask的#1)
10月3日至26日:33:02.205:I / DEBUG(933):*** *** *** *** *** *** *** *** *** *** *** * ** *** *** *** ***
10月3日至26日:33:02.205:I / DEBUG(933):建立指纹:“generic_x86 / google_sdk_x86 / generic_x86:4.4.2 / KK / 999428:主机/测试键”
10月3日至26日:33:02.205:I / DEBUG(933):修订:“0”
10月3日至26日:33:02.205:I / DEBUG(933):PID:2475,TID:2494,姓名:AsyncTask的#1>>> com.proton<<<
10月3日至26日:33:02.205:I / DEBUG(933):11(SIGSEGV),code 1(SEGV_MAPERR),故障地址deadbaad
完整的堆栈跟踪:
解决方案
毕竟我是能够解决此问题, EVP_CipherUpdate (或JNI ReleaseByteArrayElements )有时会溢出输出缓冲器造成堆损坏,没有在我的code是错误的,也是它不与主叫方如更换问题 EVP_CipherUpdate 与的memcpy 用同样的参数调用和预期一样,没有堆损坏。
于是溶液加入一些额外的长度发送到nativeUpdate和错误不见了输出缓冲区。android heap corruptionandroid heap corruption
我已经做出的库为他人在使用的完整工作版本:
https://github.com/frisco82/conceal
本文地址:IT屋 » 堆损坏 - SEGV_MAPERR在Android原生code
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-49223-2.html
大陆一打台湾
有几个公司账目不造假
收二手家电者的广告词