Jump to content
  • Advertisement
Sign in to follow this  
Moonmancer

Unity Unhandled Exceptions

This topic is 2022 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

Hello GameDev Community,

 

I'm in need of your support.

Visual Studio 2012 gives me following debug information:

 

Exception (first Chance) at 0x01263F6E in QPT.exe: 0xC0000005: Access Violation while Reading at Position 0x00000F44
Unhandeld Exception at 0x01263F6E in QPT.exe: 0xC0000005: Access Violation while Reading at Position 0x00000F44

 

#pragma once
#include "OpenGL\lib3ds\src\lib3ds.h"
#include "OpenGL\GLee\GLee.h"
#include <GL/gl.h>		// OpenGL header
#include <GL/glu.h>		// OpenGL Utility header
#include "OpenGL\freeglut\include\GL\glut.h"
class plattform {
	Lib3dsFile* model;
	Lib3dsMaterial** material;
	Lib3dsMesh** mesh;	
	Lib3dsFace* face;
	GLuint vertexVBO,normalVBO,textureVBO;
	unsigned long total_face;
	void getfaces();

public:
	double PosX,PosY,PosZ;
	double MoveX,MoveY,MoveZ;
	void drawPlatform();
	plattform(double x,double y, double z):MoveX(0),MoveY(0),MoveZ(0),PosX(x),PosY(y),PosZ(z){
		model = lib3ds_file_open("platform.3ds");
		material = model->materials;
		mesh = model->meshes;
	};
	~plattform(void);
};

 

when i debug the code line by line the error occurs at mesh = model->meshes;

 

visual studio then links me to the lib3ds_file.c to following code section:

Lib3dsFile*
lib3ds_file_open(const char *filename) {
    FILE *f;
    Lib3dsFile *file;
    Lib3dsIo io;

    f = fopen(filename, "rb");
    if (!f) {
        return NULL;
    }
    file = lib3ds_file_new();
    if (!file) {
        fclose(f);
        return NULL;
    }

    memset(&io, 0, sizeof(io));
    io.self = f;
    io.seek_func = fileio_seek_func;
    io.tell_func = fileio_tell_func;
    io.read_func = fileio_read_func;
    io.write_func = fileio_write_func;
    io.log_func = NULL;

    if (!lib3ds_file_read(file, &io)) {
        fclose(f);
        free(file);
        return NULL;
    }

    fclose(f);
    return file;
}

 

Your help would be very much appretiated.

 

best regards

Moonmancer

Edited by Moonmancer

Share this post


Link to post
Share on other sites
Advertisement

0xC0000005 error means the program has attempted to access memory that it should not. Put some breakpoints to find out on which line exactly crashes.

Also do you have some debug output messages from that Lib3ds possibly, might tell you something?

Share this post


Link to post
Share on other sites

i colored the line red maybe you skiped it^^

 

and unfortunatly i don't have lib3ds debug output msgs

Edited by Moonmancer

Share this post


Link to post
Share on other sites

Did you step thru lib3ds_file_open function with breakpoints also as 'model' might be invalid pointer?

Does execution enters this "if block" maybe?

 

if (!lib3ds_file_read(file, &io)) {
    ...
}

I noticed that you have skipped one c++ rule, when using initialization list in constructor, make sure to fill your members in order as they are declared. Although this might not be the issue you currently having.

 

plattform(double x,double y, double z)
    : model(nullptr), material(nullptr), mesh(nullptr), face(nullptr),
    vertexVBO(0), normalVBO(0), textureVBO(0), total_face(0),
    PosX(x), PosY(y), PosZ(z),
    MoveX(0), MoveY(0), MoveZ(0)
{
    ...
}
Edited by belfegor

Share this post


Link to post
Share on other sites

Yeah, I guess belfegor is right. It seems like model is null when you try to access its meshes. If a function returns a pointer and may actually return null on errors (like lib3ds_file_open does), you have to check its return value before dereferencing the pointer. Always.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!