无效的堆地址和致命的信号11 [英] Invalid heap address and fatal signal 11
问题描述
几乎每隔一段时间,我的应用程序将崩溃,我的日志将改为:
Every so often my app will crash and my log will read:
@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
有时候 code = 2
,但总是致命的信号11
和无效堆地址
。
我已经试过研究这意味着什么,以及如何解决它。 这个线程一直是最有帮助的;不过,我还是没办法解决。
I've tried researching what this means and how to fix it. This thread has been the most helpful; however, I'm still without a solution.
当我跑了几个 AsyncTasks
的下载几个图像时,会出现错误。
The error occurs when I run a couple of AsyncTasks
to download several images.
这是我的主的AsyncTask
public class FetchArtistImages extends AsyncTask<Void, Integer, String[]> implements Constants {
private final WeakReference<Context> contextReference;
public FetchArtistImages(Context context) {
contextReference = new WeakReference<Context>(context);
}
@Override
protected String[] doInBackground(Void... params) {
String[] projection = new String[] {
Audio.Artists._ID, Audio.Artists.ARTIST
};
String sortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;
Cursor c = contextReference.get().getContentResolver()
.query(uri, projection, null, null, sortOrder);
ArrayList<String> artistIds = new ArrayList<String>();
if (c != null) {
int count = c.getCount();
if (count > 0) {
final int ARTIST_IDX = c.getColumnIndex(Audio.Artists.ARTIST);
for (int i = 0; i < count; i++) {
c.moveToPosition(i);
artistIds.add(c.getString(ARTIST_IDX));
}
}
c.close();
c = null;
}
return artistIds.toArray(new String[artistIds.size()]);
}
@Override
protected void onPostExecute(String[] result) {
for (int i = 0; i < result.length; i++) {
new LastfmGetArtistImages(contextReference.get()).executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, result[i]);
}
super.onPostExecute(result);
}
尽管我已经试过研究怎么了这一点,我仍然觉得,当涉及到修复它自己丢失。如果任何人有一些见解,我肯定会AP preciate看到它。在没有引发错误,我每次执行
我的 AsyncTasks
,但我不能找到太多的图案帮助找出为什么这正在发生。有一个关于夫妻,因此其他线程致命的信号11
,但他们没有我的情况下,提供了很大帮助。
Even though I've tried researching what's up with this, I still find myself lost when it comes to fixing it. If anyone has some insight, I'd definitely appreciate seeing it. The error isn't thrown every time I execute
my AsyncTasks
, but I can't find much of a pattern to help isolate why this is occurring. There are a couple of other threads on SO about fatal signal 11
, but they don't provide much help in my case.
推荐答案
我只是碰到了同样的问题,把它在重新producable状态。这是我得到的错误:
I just ran into the same issue and had it at a re-producable state. This is the error I was getting:
08-04 17:37:05.491:A / libc的(4233):### ABORTING:无效的堆地址dlfree 08-04 17:37:05.491:A / libc的(4233):致命的信号11(SIGSEGV)在0xdeadbaad(code = 1)
08-04 17:37:05.491: A/libc(4233): @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree 08-04 17:37:05.491: A/libc(4233): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
它所归结为是正在取得函数调用从两个不同的线程同时
What it boiled down to is a function call being made from two different threads at the same time.
更具体地讲,这个功能是的BluetoothSocket的close()方法。
More specifically, this function was BluetoothSocket's close() method.
我查源$ C $ C <一个href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.1_r2/android/bluetooth/BluetoothSocket.java#BluetoothSocket.close%28%29">at本网站,呼叫不同步(不知道这是否改变了,因为它是从Android 2.1系统)。
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).
在任何情况下,你可能有其中函数调用多个线程进行了类似的情况?不能肯定地说,从你显示源$ C $ C。
At any rate, do you maybe have a similar scenario where a function call is made from multiple threads? Can't say for sure from the source code you're showing.
也有你试过没有使用THREAD_POOL_EXECUTOR?据 Android开发指南:
Also have you tried not using THREAD_POOL_EXECUTOR? According to the android dev guide:
在首次推出,AsyncTasks是连续在一个后台线程中执行。与DONUT开始,此改变为线程允许多个任务,以在并行操作的一个池。与蜂窝出发,任务是在单个线程中执行,以避免由并行执行常见的应用程序的错误。
When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.
这篇关于无效的堆地址和致命的信号11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!