Tracking down memory allocation error
Posted: Sun Oct 17, 2010 10:16 pm
I've been writing an ASE model loader for a couple of weeks now, and a single bug has eluded me for almost a week. I'm not exactly positive what is causing it, so I'll just provide the clues I'm aware of, and see if anyone with more experience can help:
- I'm using plain ANSI C
- Here is the bulk of relevant source code, and you can see everything else up there as needed: http://github.com/freemancw/Exact3D/blo ... odel_ase.c
- Here is a test ASE file that produces the bug: http://student.cs.appstate.edu/freemancw/junk/test.ASE
- If I run the code inside of eclipse with the gdb debugger, it works fine. If I run the executable, it crashes.
- I have debugging code that prints out the values of all of the fields of a given model. For test.ASE, the problematic area produces the following.
Code: Select all
Face Count: 2 <- this is correct ======================================================= Face ID: 2 <-- should be 0 A: 8, B: 2, C: 7404232, AB: 7372608, BC: 7404352, CA: 7404504 <- all of these values are wrong Smoothing Group: 1 <- from here on everything is correct Material ID: 0 Face Normal: X = 0.000000, Y = 0.000000, Z = 1.000000 Face ID: 1 A: 1, B: 3, C: 0, AB: 1, BC: 0, CA: 1 Smoothing Group: 1 Material ID: 0 Face Normal: X = 0.000000, Y = 0.000000, Z = 1.000000