@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree

っていうエラーのお話し。
開発したアプリのテストをしていると、ある処理を行うところでアプリがkillされる現象に陥った。
ぱっとみメモリ不足ではなさそうだったので頭をひねっていると、
プロセスがkillされる直前に以下のようなエラーが出ていることに気付く。

03-05 16:15:06.762: A/libc(19768): @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree
03-05 16:15:06.782: A/libc(19768): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)

いかにもネイティブのエラーですって顔してて嫌な感じだったので、
いつも通りStackOverflowを頼るときれいな回答が。


What it boiled down to is a function call being made from two different threads at the same time.
More specifically, this function was BluetoothSocket's close() method.
I checked the source code at this website , and the call is not synchronized (not sure if this changed since it is from Android 2.1).

引用元:
http://stackoverflow.com/questions/10662446/invalid-heap-address-and-fatal-signal-11(StackOverflow)

どうも異なるスレッドから同時にメソッドを呼び出すと発生するご様子。
何でsynchronizedされていないのかは分からないけど、
思いっきりBluetoothSocket#close()を使っていたので排他的に呼ばれるように修正。

コメント

このブログの人気の投稿

Activity以外からstartActivityする

in app billing v3 でサンドボックステストするときの話

XmlPullParserでのXML解析