Sign in to follow this  

file-streaming,

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alas, after fateful days of debugging and refactoring, and not a chance in hope I'll be able to track down an elusive bug, I decided to check the logfiles. I made a nice neat little error logger, so now its time to go through it and see if it yeilds anything valuable. Ah HA!
Created file streams
assigning *num_lights
Read number of lights 3

adding light0
	 Position:[ -188.635, 110.917, -194.239]
	 Color:[ 213, 208, 198]
Added light to world 
adding light1
	 Position:[ 215.097, 110.917, -194.239]
	 Color:[ 255, 198, 198]
Added light to world 
adding light2
	 Position:[ -8.89714, 110.917, 350.853]
	 Color:[ 198, 211, 255]
Added light to world 


assigning *num_materials
Read number of materials 5

Adding material 0
Material Name: walls
Creating Diffuse Texture: data\ConcreteCast-In-Place.bmp
No opacity texture
No normal texture
No bump texture
Material name: walls

Adding material 1
Material Name: box2
Creating Diffuse Texture: data\STEELPLT.bmp
No opacity texture
No normal texture
No bump texture
Material name: box2

Adding material 2
Material Name: pipe2
Creating Diffuse Texture: data\fx3_Panels_4.bmp
No opacity texture
No normal texture
No bump texture
Material name: pipe2

Adding material 3
Material Name: floor
Creating Diffuse Texture: data\MtlPlat2.bmp
Creating Opacity Texture: data\grid_mask.bmp
No normal texture
No bump texture
Material name: floor

Adding material 4
Material Name: boxes
Creating Diffuse Texture: data\Crateold.bmp
No opacity texture
No normal texture
No bump texture
Material name: boxes

adding material5
No diffuse texture
No opacity texture
Added material to world 
Material name: solid_color

done


assigning *num_objects
Read number of objects 12

adding object0
Added object to world 
read material: walls
match:0 walls
found and linked material to object
material_name:walls node->data->name:walls
Read number of polygons 56
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
adding polygon: 12
adding polygon: 13
adding polygon: 14
adding polygon: 15
adding polygon: 16
adding polygon: 17
adding polygon: 18
adding polygon: 19
adding polygon: 20
adding polygon: 21
adding polygon: 22
adding polygon: 23
adding polygon: 24
adding polygon: 25
adding polygon: 26
adding polygon: 27
adding polygon: 28
adding polygon: 29
adding polygon: 30
adding polygon: 31
adding polygon: 32
adding polygon: 33
adding polygon: 34
adding polygon: 35
adding polygon: 36
adding polygon: 37
adding polygon: 38
adding polygon: 39
adding polygon: 40
adding polygon: 41
adding polygon: 42
adding polygon: 43
adding polygon: 44
adding polygon: 45
adding polygon: 46
adding polygon: 47
adding polygon: 48
adding polygon: 49
adding polygon: 50
adding polygon: 51
adding polygon: 52
adding polygon: 53
adding polygon: 54
adding polygon: 55
verifying load 
number of polygons loaded 56
load verification succeded 

adding object1
Added object to world 
read material: pipe2
match:-1 walls
match:1 box2
match:0 pipe2
found and linked material to object
material_name:pipe2 node->data->name:pipe2
Read number of polygons 62
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
adding polygon: 12
adding polygon: 13
adding polygon: 14
adding polygon: 15
adding polygon: 16
adding polygon: 17
adding polygon: 18
adding polygon: 19
adding polygon: 20
adding polygon: 21
adding polygon: 22
adding polygon: 23
adding polygon: 24
adding polygon: 25
adding polygon: 26
adding polygon: 27
adding polygon: 28
adding polygon: 29
adding polygon: 30
adding polygon: 31
adding polygon: 32
adding polygon: 33
adding polygon: 34
adding polygon: 35
adding polygon: 36
adding polygon: 37
adding polygon: 38
adding polygon: 39
adding polygon: 40
adding polygon: 41
adding polygon: 42
adding polygon: 43
adding polygon: 44
adding polygon: 45
adding polygon: 46
adding polygon: 47
adding polygon: 48
adding polygon: 49
adding polygon: 50
adding polygon: 51
adding polygon: 52
adding polygon: 53
adding polygon: 54
adding polygon: 55
adding polygon: 56
adding polygon: 57
adding polygon: 58
adding polygon: 59
adding polygon: 60
adding polygon: 61
verifying load 
number of polygons loaded 62
load verification succeded 

adding object2
Added object to world 
read material: pipe2
match:-1 walls
match:1 box2
match:0 pipe2
found and linked material to object
material_name:pipe2 node->data->name:pipe2
Read number of polygons 62
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
adding polygon: 12
adding polygon: 13
adding polygon: 14
adding polygon: 15
adding polygon: 16
adding polygon: 17
adding polygon: 18
adding polygon: 19
adding polygon: 20
adding polygon: 21
adding polygon: 22
adding polygon: 23
adding polygon: 24
adding polygon: 25
adding polygon: 26
adding polygon: 27
adding polygon: 28
adding polygon: 29
adding polygon: 30
adding polygon: 31
adding polygon: 32
adding polygon: 33
adding polygon: 34
adding polygon: 35
adding polygon: 36
adding polygon: 37
adding polygon: 38
adding polygon: 39
adding polygon: 40
adding polygon: 41
adding polygon: 42
adding polygon: 43
adding polygon: 44
adding polygon: 45
adding polygon: 46
adding polygon: 47
adding polygon: 48
adding polygon: 49
adding polygon: 50
adding polygon: 51
adding polygon: 52
adding polygon: 53
adding polygon: 54
adding polygon: 55
adding polygon: 56
adding polygon: 57
adding polygon: 58
adding polygon: 59
adding polygon: 60
adding polygon: 61
verifying load 
number of polygons loaded 62
load verification succeded 

adding object3
Added object to world 
read material: pipe2
match:-1 walls
match:1 box2
match:0 pipe2
found and linked material to object
material_name:pipe2 node->data->name:pipe2
Read number of polygons 62
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
adding polygon: 12
adding polygon: 13
adding polygon: 14
adding polygon: 15
adding polygon: 16
adding polygon: 17
adding polygon: 18
adding polygon: 19
adding polygon: 20
adding polygon: 21
adding polygon: 22
adding polygon: 23
adding polygon: 24
adding polygon: 25
adding polygon: 26
adding polygon: 27
adding polygon: 28
adding polygon: 29
adding polygon: 30
adding polygon: 31
adding polygon: 32
adding polygon: 33
adding polygon: 34
adding polygon: 35
adding polygon: 36
adding polygon: 37
adding polygon: 38
adding polygon: 39
adding polygon: 40
adding polygon: 41
adding polygon: 42
adding polygon: 43
adding polygon: 44
adding polygon: 45
adding polygon: 46
adding polygon: 47
adding polygon: 48
adding polygon: 49
adding polygon: 50
adding polygon: 51
adding polygon: 52
adding polygon: 53
adding polygon: 54
adding polygon: 55
adding polygon: 56
adding polygon: 57
adding polygon: 58
adding polygon: 59
adding polygon: 60
adding polygon: 61
verifying load 
number of polygons loaded 62
load verification succeded 

adding object4
Added object to world 
read material: box2
match:-1 walls
match:0 box2
found and linked material to object
material_name:box2 node->data->name:box2
Read number of polygons 20
    Tðä	Tðä	/ÇB§øCFTtÃ4U†?sç¿@Dß?            on: 1
adding/ÇB§øCK—–Ã~	:sç¿@@ß?             polygon: 4
„™Á¨øCK—–Ã~	:  @@@ß?            addiï	4  €?"F›(7
ad    êä	à9@
„:@
9@
    Tðä	Tðä	²ø	èøCHTtà |	: kD; :             11
adding p²ø	à ߇BHTtÃ5U†? kD; ð:             polygon: 14£„™Á߇BGTtÃ5U†?  @@ ð:            16
adding polygon: 1 adding pol<;@
: 18
adding polygon: 19
verifying load 
number of polygons loaded 20
load verification succeded 

adding object5
Added object to world 
read material: box2
match:-1 walls
match:0 box2
found and linked material to object
material_name:box2 node->data->name:box2
Read number of polygons 20
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
adding polygon: 12
adding polygon: 13
adding polygon: 14
adding polygon: 15
adding polygon: 16
adding polygon: 17
adding polygon: 18
adding polygon: 19
verifying load 
number of polygons loaded 20
load verification succeded 

adding object6
Added object to world 
read material: floor
match:-1 walls
match:1 box2
match:-1 pipe2
match:0 floor
found and linked material to object
material_name:floor node->data->name:floor
Read number of polygons 2
reading polygons 
adding polygon: 0
adding polygon: 1
verifying load 
number of polygons loaded 2
load verification succeded 

adding object7
Added object to world 
read material: boxes
match:-1 walls
match:1 box2
match:-1 pipe2
match:-1 floor
match:0 boxes
found and linked material to object
material_name:boxes node->data->name:boxes
Read number of polygons 12
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
verifying load 
number of polygons loaded 12
load verification succeded 

adding object8
Added object to world 
read material: boxes
match:-1 walls
match:1 box2
match:-1 pipe2
match:-1 floor
match:0 boxes
found and linked material to object
material_name:boxes node->data->name:boxes
Read number of polygons 12
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
verifying load 
number of polygons loaded 12
load verification succeded 

adding object9
Added object to world 
read material: boxes
match:-1 walls
match:1 box2
match:-1 pipe2
match:-1 floor
match:0 boxes
found and linked material to object
material_name:boxes node->data->name:boxes
Read number of polygons 12
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
verifying load 
number of polygons loaded 12
load verification succeded 

adding object10
Added object to world 
read material: boxes
match:-1 walls
match:1 box2
match:-1 pipe2
match:-1 floor
match:0 boxes
found and linked material to object
material_name:boxes node->data->name:boxes
Read number of polygons 12
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
verifying load 
number of polygons loaded 12
load verification succeded 

adding object11
Added object to world 
read material: boxes
match:-1 walls
match:1 box2
match:-1 pipe2
match:-1 floor
match:0 boxes
found and linked material to object
material_name:boxes node->data->name:boxes
Read number of polygons 12
reading polygons 
adding polygon: 0
adding polygon: 1
adding polygon: 2
adding polygon: 3
adding polygon: 4
adding polygon: 5
adding polygon: 6
adding polygon: 7
adding polygon: 8
adding polygon: 9
adding polygon: 10
adding polygon: 11
verifying load 
number of polygons loaded 12
load verification succeded 

finished loading maps/testmesh.dat

what worries me the most is
found and linked material to object
material_name:box2 node->data->name:box2
Read number of polygons 20
    Tðä	Tðä	/ÇB§øCFTtÃ4U†?sç¿@Dß?            on: 1
adding/ÇB§øCK—–Ã~	:sç¿@@ß?             polygon: 4
„™Á¨øCK—–Ã~	:  @@@ß?            addiï	4  €?"F›(7
ad    êä	à9@
„:@
9@
    Tðä	Tðä	²ø	èøCHTtà |	: kD; :             11
adding p²ø	à ߇BHTtÃ5U†? kD; ð:             polygon: 14£„™Á߇BGTtÃ5U†?  @@ ð:            16
adding polygon: 1 adding pol<;@
: 18
adding polygon: 19
verifying load 
simply put: WTF?! I'm using streams for the error log, and I have NO idea how I could bork it that badly. Does anyone have any insight at all as to how it possible to bamboozle a stream like this? I'm completely lost as to how I've managed to mess this up. Also, all of the data read at that point is also corrupted. I first noticed to problem when I was trying to generate gl display lists and I could access the data. The same data which is being read when the errlog goes kapoot. Thanks in advance. Cheers

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by aaron_ds
Alas, after fateful days of debugging and refactoring, and not a chance in hope I'll be able to track down an elusive bug,


Quote:

I'm completely lost as to how I've managed to mess this up.
Also, all of the data read at that point is also corrupted. I first noticed to problem when I was trying to generate gl display lists and I could access the data. The same data which is being read when the errlog goes kapoot.


Its just a long shot (because I dont know what your logging code looks like or what the original problem is), but is it possible that the logger is fine and is printing corrupted data - which is the cause of your original problem?

Id step through the debugger to verify this and map the memory while going through the routines.


Hope that helps..


#dth-0

Share this post


Link to post
Share on other sites
Quote:
Original post by aaron_ds
Alas, after fateful days of debugging and refactoring, and not a chance in hope I'll be able to track down an elusive bug,


Quote:

I'm completely lost as to how I've managed to mess this up.
Also, all of the data read at that point is also corrupted. I first noticed to problem when I was trying to generate gl display lists and I could access the data. The same data which is being read when the errlog goes kapoot.


Its just a long shot (because I dont know what your logging code looks like or what the original problem is), but is it possible that the logger is fine and is printing corrupted data - which is the cause of your original problem?

Id step through the debugger to verify this and map the memory while going through the routines.


Hope that helps..


#dth-0

Share this post


Link to post
Share on other sites
/*build polygon linked list*/
for(int i=0; i<*num_polygons; i++){
errlog<<"adding polygon: "<<i<<"\n";
file>>object.polygon_list.append();
}




Thats the simple polygon loading loop.
file is an ifstream.

overload the >> operator for streaming filedata into polygons

ifstream& operator>>(ifstream& file, POLYGON& poly){
file>>poly.normal;
file>>poly.verts[0];
file>>poly.verts[1];
file>>poly.verts[2];
return file;
}




file is eventually cascaded into:
ifstream& operator>>(ifstream& file, POINT3f& point){
if(!&point || !&file)
return file;
file.read((char*)(&(point.x)), sizeof(float));
file.read((char*)(&(point.y)), sizeof(float));
file.read((char*)(&(point.z)), sizeof(float));
return file;
}



I'm confused as to why everything is read fine until a point, then corrupted, then read fine after that.

Share this post


Link to post
Share on other sites
could lots of things...

memory corruption would be my guess. Are you allocating enough buffer space for your data? If you think you do, try to allocate the same amount plus some extra, and run the test again. if the memory corruption happens further down, then your memory allocator could be not working properly. Although, you should get an access violation at some point.

when you create the ifstream, do you create the buufer allocation before? something like

char* buffer;
ifstream file;

when you do file.read((char*)(&(point.x)), sizeof(float));, can't you do fille>>point.x; directly?

when you read vectors, do sanity checks, like check the exponent part of the vector you read, vaildate floats by checking if the exponent part is corrupted.

if ((((*(int *)&float_number) >> 23) & 0x8F) > 32)
Assert("Invalid floating point number");

not sure if this is correct, but someone will correct me on that.

Could also be that your importer is missing something about the object format. maybe this object as something particular about it, like reflection maps, or flags, and you missed something, therefore, all the data is offset in the file. But I doubt.

when reaching object4, flush the stream, check the file, and step by step through the log outputs, while flushing the log buffer everytime you output something.

I'm just guessing though....

Share this post


Link to post
Share on other sites

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this