#132234 - Mr Snowflake - Sun Jun 24, 2007 10:36 pm
*** EDIT see below ***
Hi guys,
I'm working on a .bsp (V30 - half-life) loader/renderer. But when I try to allocate some memory on the heap I get a: *** glibc detected *** /home/mrsnowflake/Projects/c/snow3d/debug/src/snow3d: malloc(): memory corruption: 0x0810a5c0 ***. I tried it on my desktop and on my laptop, but they both give the same error. Both my computers are running ubuntu, so maybe I should try some other os.
This is the code genereting the error:
the readLump reads some data from a file. The program usely crashes at clipNode = new ClipNode[header->clipnodes.size/sizeof(ClipNode)]; Does any one as an idea why this is happening?
I just discovered the issue only exists when I setup SDL first. If I comment all the SDL stuff the allocation runs perfectly, but when I just SDL_Init( SDL_INIT_VIDEO ) the problem exists.
EDIT: Well, I think it's a SDL problem. When I load the map before I setup SDL, the code crashes when gdb gets at SDL_Init( SDL_INIT_VIDEO )... So I probably need to fix sdl or work around sdl...
_________________
http://www.mrsnowflake.be
Hi guys,
I'm working on a .bsp (V30 - half-life) loader/renderer. But when I try to allocate some memory on the heap I get a: *** glibc detected *** /home/mrsnowflake/Projects/c/snow3d/debug/src/snow3d: malloc(): memory corruption: 0x0810a5c0 ***. I tried it on my desktop and on my laptop, but they both give the same error. Both my computers are running ubuntu, so maybe I should try some other os.
This is the code genereting the error:
Code: |
planes = new Plane[header->planes.size/sizeof(Plane)];
if(!readLump(planes, header->planes.offset, header->planes.size)) return false; //textureLumpHeader = &header + header->directory[LUMP_FACES].offset; //mipTex = &header + header->directory[LUMP_FACES].offset; vertices = new Vertex_t[header->vertices.size/sizeof(Vertex_t)]; if(!readLump(vertices, header->vertices.offset, header->vertices.size)) return false; listOfFaces = new faceList[header->lface.size/sizeof(faceList)]; if(!readLump(listOfFaces, header->lface.offset, header->lface.size)) return false; listOfEdges = new surfedge[header->ledges.size/sizeof(surfedge)]; if(!readLump(listOfEdges, header->ledges.offset, header->ledges.size)) return false; nodes = new Node[header->nodes.size/sizeof(Node)]; if(!readLump(nodes, header->nodes.offset, header->nodes.size)) return false; //texInfo = &header + header->directory[LUMP_FACES].offset; faces = new Face[header->faces.size/sizeof(Face)]; if(!readLump(faces, header->faces.offset, header->faces.size)) return false; leaves = new Leaf[header->leaves.size/sizeof(Leaf)]; if(!readLump(leaves, header->leaves.offset, header->leaves.size)) return false; clipNode = new ClipNode[header->clipnodes.size/sizeof(ClipNode)]; if(!readLump(clipNode, header->clipnodes.offset, header->clipnodes.size)) return false; edges = new Edge[header->edges.size/sizeof(Edge)]; if(!readLump(edges, header->edges.offset, header->edges.size)) return false; models = new Model[header->models.size/sizeof(Model)]; if(!readLump(models, header->models.offset, header->models.size)) return false; |
the readLump reads some data from a file. The program usely crashes at clipNode = new ClipNode[header->clipnodes.size/sizeof(ClipNode)]; Does any one as an idea why this is happening?
I just discovered the issue only exists when I setup SDL first. If I comment all the SDL stuff the allocation runs perfectly, but when I just SDL_Init( SDL_INIT_VIDEO ) the problem exists.
EDIT: Well, I think it's a SDL problem. When I load the map before I setup SDL, the code crashes when gdb gets at SDL_Init( SDL_INIT_VIDEO )... So I probably need to fix sdl or work around sdl...
_________________
http://www.mrsnowflake.be