SculptMode fix:
DNA definition of Sculpt structs in Scene were not properly aligned, causing memory errors on quit ("Memoryblock reconstruct: end corrupt"). More testing reveiled padding errors in two other DNA_ includes, for sound and gamelogic. Both potentially crashers... and caused by commenting out struct members with a C++ comment, that seems to not work... I've revived the DNA padding test method, which saves out a simple C file you can compile to see where padding issues are. This now works as follows: - change line 991 in makesdna.c to become (1) (true). - recompile makesdna.c - you now have a padding.c in the same dir as makesdna.c - compile it, command line: "gcc -o padding padding.c" - now run it (./padding), and it will print out errors, if there are. For me, the DNA files are now 100% padding free. Might be interesting to check it in 64 bits though!
This commit is contained in:
parent
6ede6352ed
commit
ced3b0fd6f
|
@ -104,8 +104,6 @@ typedef struct bObjectActuator {
|
|||
float loc[3], rot[3];
|
||||
float dloc[3], drot[3];
|
||||
float linearvelocity[3], angularvelocity[3];
|
||||
// float addedlinearvelocity[3];
|
||||
// char anotherpad[4];
|
||||
} bObjectActuator;
|
||||
|
||||
typedef struct bIpoActuator {
|
||||
|
|
|
@ -367,12 +367,14 @@ typedef struct BrushData
|
|||
short size;
|
||||
char strength, dir; /* Not used for smooth brush */
|
||||
char airbrush;
|
||||
char pad[7];
|
||||
char pad[3];
|
||||
} BrushData;
|
||||
|
||||
struct PropsetData;
|
||||
struct RenderInfo;
|
||||
struct SculptUndo;
|
||||
|
||||
/* DNA WARNING: use of doubles forces SculptData internal alignment to 8 (only in gcc?) */
|
||||
typedef struct SculptData
|
||||
{
|
||||
/* Cache of the OpenGL matrices */
|
||||
|
@ -396,10 +398,10 @@ typedef struct SculptData
|
|||
|
||||
struct PropsetData *propset;
|
||||
|
||||
struct SculptUndo *undo;
|
||||
struct SculptUndo *undo, *padp; /* pointer pad! */
|
||||
|
||||
/* For rotating around a pivot point */
|
||||
vec3f pivot;
|
||||
vec3f pivot, padv; /* vec3f is 12 bytes */
|
||||
|
||||
/* Settings for each brush */
|
||||
BrushData drawbrush, smoothbrush, pinchbrush, inflatebrush, grabbrush, layerbrush;
|
||||
|
@ -417,11 +419,11 @@ typedef struct SculptData
|
|||
short texscale;
|
||||
short texact, texnr;
|
||||
short spacing;
|
||||
char pad[2];
|
||||
char pad;
|
||||
char texrept;
|
||||
char texfade;
|
||||
|
||||
char averaging, pad2[3];
|
||||
char averaging;
|
||||
} SculptData;
|
||||
|
||||
#define SCULPTREPT_DRAG 1
|
||||
|
|
|
@ -103,8 +103,6 @@ typedef struct bSound {
|
|||
float distance;
|
||||
int flags;
|
||||
int streamlen;
|
||||
// unsigned int loopstart;
|
||||
// unsigned int loopend;
|
||||
char channels;
|
||||
char highprio;
|
||||
char pad[10];
|
||||
|
|
|
@ -141,7 +141,7 @@ int nr_structs=0;
|
|||
char **names, *namedata; /* at adress names[a] is string a */
|
||||
char **types, *typedata; /* at adress types[a] is string a */
|
||||
short *typelens; /* at typelens[a] is de length of type a */
|
||||
short *alphalens; /* contains sizes as they are calculated on the alpha */
|
||||
short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits) */
|
||||
short **structs, *structdata; /* at sp= structs[a] is the first adress of a struct definition
|
||||
sp[0] is type number
|
||||
sp[1] is amount of elements
|
||||
|
@ -870,7 +870,7 @@ int make_structDNA(char *baseDirectory, FILE *file)
|
|||
add_type("short", 2); /* 2 */
|
||||
add_type("ushort", 2); /* 3 */
|
||||
add_type("int", 4); /* 4 */
|
||||
add_type("long", 4); /* 5 */
|
||||
add_type("long", 4); /* 5 */ /* should it be 8 on 64 bits? */
|
||||
add_type("ulong", 4); /* 6 */
|
||||
add_type("float", 4); /* 7 */
|
||||
add_type("double", 8); /* 8 */
|
||||
|
@ -988,7 +988,6 @@ int make_structDNA(char *baseDirectory, FILE *file)
|
|||
dna_write(file, structs[0], len);
|
||||
|
||||
/* a simple dna padding test */
|
||||
|
||||
if (0) {
|
||||
FILE *fp;
|
||||
int a;
|
||||
|
@ -999,16 +998,18 @@ int make_structDNA(char *baseDirectory, FILE *file)
|
|||
|
||||
// add all include files defined in the global array
|
||||
for (i = 0; strlen(includefiles[i]); i++) {
|
||||
fprintf(fp, "#include \"%s\"\n", includefiles[i]);
|
||||
fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]);
|
||||
}
|
||||
|
||||
fprintf(fp, "main(){\n");
|
||||
sp = typelens;
|
||||
sp += firststruct;
|
||||
for(a=firststruct; a<nr_types; a++, sp++) {
|
||||
fprintf(fp, "\tprintf(\" ");
|
||||
fprintf(fp, "%%d %s %d ", types[a], *sp);
|
||||
fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
|
||||
if(*sp) {
|
||||
fprintf(fp, "\tif(sizeof(struct %s) - %d) printf(\"ALIGN ERROR:", types[a], *sp);
|
||||
fprintf(fp, "%%d %s %d ", types[a], *sp);
|
||||
fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
|
||||
}
|
||||
}
|
||||
fprintf(fp, "}\n");
|
||||
fclose(fp);
|
||||
|
|
Loading…
Reference in New Issue