www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Error: Access Violation

reply Ant <duitoolkit yahoo.ca> writes:
I have this program that runs on linux but crashs on windows:

class A
{
	bit mA()
	{
		prinf("entry A\n");
		// calls to external C libs
		printf("exit A\n");
		return true
	}
}
class B : A
{
	bit mB()
	{
		prinf("entry B\n");
		mA();
		printf("exit B\n");
		return true
	}
}

and this prints:
entry B
entry A
exit A

and crashes. It never reaches the printf just after the 
return from mA

how can that be?
Am I messing with the stack?
The pure C examples that use my external calls run perfectly.

There are no other threads running, wait,
let me suspend the GC...no luck: same result.

Ant

PS
this it OpenGL support for DUI on windows,
seems only the simplest OpenGL progams will run on DUI windows :(
Nov 14 2004
next sibling parent reply Ant <duitoolkit yahoo.ca> writes:
On Sun, 14 Nov 2004 17:52:02 -0500, Ant wrote:

 I have this program that runs on linux but crashs on windows:
 
ok only crashs on glFrustum(), so never mind is the gl thing that is to blaim, some how. Ant
Nov 14 2004
parent h3r3tic <foo bar.baz> writes:
Ant wrote:

 On Sun, 14 Nov 2004 17:52:02 -0500, Ant wrote:
 
 
I have this program that runs on linux but crashs on windows:
ok only crashs on glFrustum(), so never mind is the gl thing that is to blaim, some how. Ant
Now that is weird. glFrustum should be able to eat all kinds of params given to it. if the function is loaded dynamically maybe the address or params are wrong... no more clues :/
Nov 14 2004
prev sibling next sibling parent h3r3tic <foo bar.baz> writes:
Ant wrote:

 I have this program that runs on linux but crashs on windows:
 
 class A
 {
 	bit mA()
 	{
 		prinf("entry A\n");
 		// calls to external C libs
 		printf("exit A\n");
 		return true
 	}
 }
 class B : A
 {
 	bit mB()
 	{
 		prinf("entry B\n");
 		mA();
 		printf("exit B\n");
 		return true
 	}
 }
 
 and this prints:
 entry B
 entry A
 exit A
 
 and crashes. It never reaches the printf just after the 
 return from mA
 
 how can that be?
 Am I messing with the stack?
 The pure C examples that use my external calls run perfectly.
 
 There are no other threads running, wait,
 let me suspend the GC...no luck: same result.
 
 Ant
 
 PS
 this it OpenGL support for DUI on windows,
 seems only the simplest OpenGL progams will run on DUI windows :(
 
How about posting some more source ? e.g. the complete program that crashes if that's possible. Or a minimal crashing program similar to this one of yours. I have a few opengl apps in D and they run fine...
Nov 14 2004
prev sibling parent reply John Reimer <John_member pathlink.com> writes:
In article <pan.2004.11.14.22.52.02.426422 yahoo.ca>, Ant says...
I have this program that runs on linux but crashs on windows:

class A
{
	bit mA()
	{
		prinf("entry A\n");
		// calls to external C libs
		printf("exit A\n");
		return true
	}
}
No semicolon after "return true"?
class B : A
{
	bit mB()
	{
		prinf("entry B\n");
		mA();
		printf("exit B\n");
		return true
	}
}
No semicolon here either?
and this prints:
entry B
entry A
exit A

and crashes. It never reaches the printf just after the 
return from mA

how can that be?
Am I messing with the stack?
The pure C examples that use my external calls run perfectly.

There are no other threads running, wait,
let me suspend the GC...no luck: same result.

Ant

PS
this it OpenGL support for DUI on windows,
seems only the simplest OpenGL progams will run on DUI windows :(
I don't know if the missing semicolons would cause the problem (or maybe it was just typed into the newsgroup post wrong). I would think that the D compiler would catch that... Later, John
Nov 14 2004
parent reply h3r3tic <foo bar.baz> writes:
John Reimer wrote:
 I don't know if the missing semicolons would cause the problem (or maybe it was
 just typed into the newsgroup post wrong).  I would think that the D compiler
 would catch that...
 
 Later,
 
 John
Nope, that can't be the problem... also there's prinf instead of printf so he didn't paste his code...
Nov 14 2004
parent reply John Reimer <John_member pathlink.com> writes:
In article <cn8p69$396$1 digitaldaemon.com>, h3r3tic says...
Nope, that can't be the problem... also there's prinf instead of printf 
so he didn't paste his code...
Good point. - John
Nov 14 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Sun, 14 Nov 2004 23:27:16 +0000, John Reimer wrote:

 In article <cn8p69$396$1 digitaldaemon.com>, h3r3tic says...
Nope, that can't be the problem... also there's prinf instead of printf 
so he didn't paste his code...
Good point. - John
Sorry, guys, I did not copy/past it. I thought it would be easier to read D than my excuse for english. glFrustum() does not exist, it require parameters... Ant
Nov 14 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
here it is a copy past version, you gonna like it ;)
funny thing is that "version=glFloat" fails
but the "else" version is OK!
OpenGL on DUI for windows might be just around the corner
I'm blaiming DMD on this one also interesting to know
that DUI OpenGL extensions never worked for windows and
that's since version 0.70 or close.

(BTW this D code is from converted the GtkGlExt examples
and is GPL not LGPL.)

have fun! (I should probably post this on the bugs group)


   bit resizeGL(EventConfigure event = null)
   {

     writefln("resizeGL 1");
     GLfloat w = getWidth();
     GLfloat h = getHeight();

     double aspect;

     glViewport (0, 0, cast(int)w, cast(int)h);

     glMatrixMode (GL_PROJECTION);
     glLoadIdentity ();
     writefln("w=%s h=%s",w,h);
     version(glFloat)
     {
       if (w <h)
       {
         aspect = w / h;
         glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 60.0);
       }
       else
       {
         aspect = h / w;
         glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 60.0);
       }
     }
     else
     {
       double a = h / w;
       glFrustum(-1.0,1.0, -a, a, 5.0, 60.0);
     }

     glMatrixMode (GL_MODELVIEW);

     writefln("resizeGL exit");
     return true;
   }

output for the good version with the non relevante lines tabed right:

		initGL 1
		initGL exit
		configureFrame 1
		configureFrame 2
resizeGL 1
w=300 h=300
resizeGL exit
		here
		configureFrame 3
		configureFrame 4
		configureFrame 5
		configureFrame 8
		configureFrame 9
		initGL 1
		initGL exit
		drawGL 1
		drawGL exit


Ant
Nov 14 2004
parent reply h3r3tic <foo bar.baz> writes:
Ant wrote:
 
 here it is a copy past version, you gonna like it ;)
 funny thing is that "version=glFloat" fails
 but the "else" version is OK!
 OpenGL on DUI for windows might be just around the corner
 I'm blaiming DMD on this one also interesting to know
 that DUI OpenGL extensions never worked for windows and
 that's since version 0.70 or close.
 (...)
Well, IMO this code is fine... my only guess of code that could crash the whole thing is that you define glFrustum as taking 6 floats (instead of doubles) when version(glFloat) is set... With this code I can't guess more... maybe if you posted your sources somewhere so that more people could compile and fight them, it could be solved... As for the moment, ensure that your glFrustum is defined as taking 6 doubles... No more ideas :( </h3>
Nov 15 2004
parent Ant <Ant_member pathlink.com> writes:
In article <cna2ap$21la$1 digitaldaemon.com>, h3r3tic says...
Ant wrote:
 
 here it is a copy past version, you gonna like it ;)
 funny thing is that "version=glFloat" fails
 but the "else" version is OK!
 OpenGL on DUI for windows might be just around the corner
 I'm blaiming DMD on this one also interesting to know
 that DUI OpenGL extensions never worked for windows and
 that's since version 0.70 or close.
 (...)
Well, IMO this code is fine... my only guess of code that could crash the whole thing is that you define glFrustum as taking 6 floats (instead of doubles) when version(glFloat) is set...
no, I created version glFloat just for posting. asptect use to be of type GLfloat (alias float GLfloat).
 With this code I can't guess 
more... maybe if you posted your sources somewhere so that more people 
could compile and fight them, it could be solved...
this is distributed with DUI since a early version. it runs fine on linux (which might be irrelevant for the windows version). http://cvs.sourceforge.net/viewcvs.py/dui/DUI/src/testGL/TestGL.d?view=markup shapesGL.d (as oposed to TestGL.d) contains the same piece of code but replacing it didn't solve the it. Seems to me then this problem runs depper. I'll have to go back on what I posted and declare the OpenGL is still not available for DUI on windows... the problem is to reduce it and remove dependencies on DUI and libgtkglext. and until that I can't be sure it isn't a problem with the gl extensions. Ant
As for the moment, ensure that your glFrustum is defined as taking 6 
doubles...
glFrustum is all doubles. and there is only one defined so both version of the code should produce the same result...
No more ideas :(
thank you any way! Ant
Nov 15 2004