I'm trying to create a small library for AES encryption for a stream, I started my work on the basis of the Facebook Conceal project ( https://github.com/facebook/conceal ) just changing some things and improving the wrapper around the native to support ciphers with addition.
It works, and it can decrypt files without problems, but I get random heap memory corruption when I work with large threads, and after a lot of debugging time, I could not find the error.
Here is my code:
https://gist.github.com/frisco82/9782725
I tried to find memory allocation or free problems, but there is almost no malloc or free, and the jni call should be safe, the same goes for opensl (I compiled my own, but the hidden ones also failed)
CheckJni doesnβt warn about anything, and although handling the context is a bit out of the box, it doesn't seem to be broken (indeed, Android encryption seems to use something similar).
In addition, if someone can point me to the native AES multiprocessor (several update requests), I will switch to it and forget it.
The error changes from time to time, but it usually looks like it:
03-26 10:33:02.065: A/dalvikvm(2475): @@@ ABORTING: DALVIK: HEAP MEMORY CORRUPTION IN mspace_malloc addr=0x0 03-26 10:33:02.065: A/libc(2475): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 2494 (AsyncTask
Full stack trace:
http://pastebin.com/f6mDuQEj