我正在實施一個分而治之的多項式算法,所以我可以將它與OpenCL實現進行基準測試,但是我無法獲得malloc
的工作。當我運行程序時,它會分配一堆東西,檢查一些東西,然後將size/2
發送給算法。然後,當我再次命中malloc
線就吐出了這一點:爲什麼我得到一個C malloc斷言失敗?
malloc.c:3096:SYSMALLOC:斷言`(old_top ==(((mbinptr)(((字符*)&((AV) - > bins [((1) - 1)* 2]))__builtin_offsetof(struct malloc_chunk,fd))))& & old_size == 0)|| ((unsigned long)(old_size)> =(unsigned long)((((_builtin_offsetof(struct malloc_chunk,fd_nextsize))+((2 *(sizeof(size_t)))-1)&〜((2 * (爲size_t))) - 1)))& &((old_top) - >大小爲0x1 &)& &((無符號長整數)OLD_END & pagemask)== 0)」失敗。 中止
所討論的行是:
int *mult(int size, int *a, int *b) {
int *out,i, j, *tmp1, *tmp2, *tmp3, *tmpa1, *tmpa2, *tmpb1, *tmpb2,d, *res1, *res2;
fprintf(stdout, "size: %d\n", size);
out = (int *)malloc(sizeof(int) * size * 2);
}
我檢查尺寸與fprintf
,並且它是一個正整數(通常爲50在該點處)。我試着用普通電話號碼撥打malloc
,我仍然遇到了錯誤。我只是不知道發生了什麼,而迄今爲止我發現的任何Google都沒有什麼幫助。
任何想法發生了什麼?我試圖弄清楚如何編譯一個新的GCC以防萬一它是編譯器錯誤,但我真的懷疑它。
我懷疑問題實際上是一個線路之前。也許雙免費?在程序 – 2010-06-07 05:21:10
第三行: INT * MULT(INT大小,INT *一個,INT * B) { \t INT *總分,I,J,* TMP1,* TMP2,* TMP3,* tmpa1 ,* tmpa2,* tmpb1,* tmpb2,d,* res1,* res2; \t fprintf(stdout,「size:%d \ n」,size); \t \t out =(int *)malloc(sizeof(int)* size * 2); – Chris 2010-06-07 05:22:33