***检测到glibc *** ./cube:双重释放或损坏(!prev):0x0a4c4420 *** [英] *** glibc detected *** ./cube: double free or corruption (!prev): 0x0a4c4420 ***

查看:121
本文介绍了***检测到glibc *** ./cube:双重释放或损坏(!prev):0x0a4c4420 ***的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

333         glGenBuffers(surftotal, uiVBO);
334         {
335                 for(surfnum=0; surfnum<surftotal; ++surfnum)
336                 {
337                         glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
338                         size_t buf_size = 9*sizeof(GLfloat)*triNum[surfnum];
339                         GLfloat* const pData = (GLfloat*)malloc(buf_size);
340                         for(i=0; i<triNum[surfnum]; ++i){
341                                 memcpy(pData+i*9,   triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
342                                 memcpy(pData+i*9+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
343                                 memcpy(pData+i*9+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
344                                 }
345                                 glBufferData(GL_ARRAY_BUFFER, buf_size, pData, GL_STATIC_DRAW);
346                                 free(pData);
347                 }
348                 glBindBuffer(GL_ARRAY_BUFFER, 0);
349                 glEnableVertexAttribArray(VERTEX_ARRAY);
350                 for(surfnum=0; surfnum<surftotal; ++surfnum)
351                 {
352                         glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
353                         glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
354                         glDrawArrays(GL_TRIANGLES, 0, 3*triNum[surfnum]);
355                         if (!TestEGLError("glDrawArrays"))
356                         {
357                         goto cleanup;
358                         }
359                 }
360                 glBindBuffer(GL_ARRAY_BUFFER, 0);
361                 eglSwapBuffers(eglDisplay, eglSurface);
362 
363                 if (!TestEGLError("eglSwapBuffers"))
364                 {
365                         goto cleanup;
366                 }
367 
368                 int i32NumMessages = XPending( x11Display );
369                 for( int i = 0; i < i32NumMessages; i++ )
370                 {
371                         XEvent  event;
372                         XNextEvent( x11Display, &event );
373                 }
374         }
375         glDeleteBuffers(surftotal,uiVBO);


实际上,当我尝试在


Actually what i am doing is generating triangles here when i try to print

triNum[surfnum]

之后打印

size_t buf_size = 9*sizeof(GLfloat)*triNum[surfnum];

时,我在这里生成三角形,它给出7 1,但是当我尝试在

it gives 7 1 but when I try to print same after

for(i=0; i&lt;triNum[surfnum]; ++i) 

之后打印相同的打印机时,它说

it says

7...7...7...7...7...7...7...Aborted

,还检测到Glibc.所以我在做什么错.

我用valgrind输出是

and also Glibc detected . So what wrong am i doing.

I use valgrind its output was

<pre lang="msil">==8922== Memcheck, a memory error detector
==8922== Copyright (C) 2002-2010, and GNU GPL''d, by Julian Seward et al.
==8922== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==8922== Command: ./cube
==8922==
libEGL warning: use software fallback
==8922== Invalid write of size 1
==8922==    at 0x4027418: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A48F: main (Hello.cpp:343)
==8922==  Address 0x9391567 is 11 bytes after a block of size 252 alloc''d
==8922==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==8922==    by 0x804A3EC: main (Hello.cpp:339)
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027420: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A48F: main (Hello.cpp:343)
==8922==  Address 0x9391566 is 10 bytes after a block of size 252 alloc''d
==8922==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==8922==    by 0x804A3EC: main (Hello.cpp:339)
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027429: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A48F: main (Hello.cpp:343)
==8922==  Address 0x9391565 is 9 bytes after a block of size 252 alloc''d
==8922==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==8922==    by 0x804A3EC: main (Hello.cpp:339)
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027432: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A48F: main (Hello.cpp:343)
==8922==  Address 0x9391564 is 8 bytes after a block of size 252 alloc''d
==8922==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==8922==    by 0x804A3EC: main (Hello.cpp:339)
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027418: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A4E3: main (Hello.cpp:344)
==8922==  Address 0x9391573 is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027420: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A4E3: main (Hello.cpp:344)
==8922==  Address 0x9391572 is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027429: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A4E3: main (Hello.cpp:344)
==8922==  Address 0x9391571 is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027432: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A4E3: main (Hello.cpp:344)
==8922==  Address 0x9391570 is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027418: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A539: main (Hello.cpp:345)
==8922==  Address 0x939157f is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027420: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A539: main (Hello.cpp:345)
==8922==  Address 0x939157e is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027429: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A539: main (Hello.cpp:345)
==8922==  Address 0x939157d is not stack''d, malloc''d or (recently) free''d
==8922==
==8922== Invalid write of size 1
==8922==    at 0x4027432: memcpy (mc_replace_strmem.c:497)
==8922==    by 0x804A539: main (Hello.cpp:345)
==8922==  Address 0x939157c is not stack''d, malloc''d or (recently) free''d
==8922==
--8922-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting
--8922-- si_code=1;  Faulting address: 0xC8B91574;  sp: 0x62a5ce00
valgrind: the ''impossible'' happened:
   Killed by fatal signal
==8922==    at 0x38031511: unlinkBlock (m_mallocfree.c:245)
sched status:
  running_tid=1
Thread 1: status = VgTs_Runnable
==8922==    at 0x4024F12: calloc (vg_replace_malloc.c:467)
==8922==    by 0x48D068A: softpipe_resource_create (sp_texture.c:114)
==8922==    by 0x4A50D96: st_bufferobj_data (u_inlines.h:180)
==8922==    by 0x4A1BB4E: _mesa_BufferDataARB (bufferobj.c:1177)
==8922==    by 0x49BFFD7: _es_BufferData (api_exec_es2.c:391)
==8922==    by 0x804A561: main (Hello.cpp:347)



但我无法确定这是否可以告诉我.



but I was unable to figure out from this may be you can tell me.

推荐答案

您是否意识到以下几行
Did you realize the following lines
sudhanshu2511写道:
sudhanshu2511 wrote:

{
memcpy(pData + i * 9,triArray [surfnum] [i] .pt1,3 * sizeof(GLfloat));
memcpy(pData + i * 9 + 3,triArray [surfnum] [i] .pt2,3 * sizeof(GLfloat));
memcpy(pData + i * 9 + 6,triArray [surfnum] [i] .pt3,3 * sizeof(GLfloat));
}

{
memcpy(pData+i*9, triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
memcpy(pData+i*9+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
memcpy(pData+i*9+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
}


外部for循环?


are outside the for loop?


这篇关于***检测到glibc *** ./cube:双重释放或损坏(!prev):0x0a4c4420 ***的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆