Dereferencing Null Pointer

Pages: 123
closed account (4z0M4iN6)

MyFirstApp.exe!b2World::Step() + 0x6 bytes C++

6 Bytes from beginning of Step() cannot be much. Should be the first line.
closed account (4z0M4iN6)
Cire wrote:

You aren't, by chance, destroying bodies while the step is happening?

Maybe you should write @JonB

So that he knows, he is ment and not me.
Last edited on
dadabe wrote:
and the first two error messages from the stack call and showed you what they mean.
The stack call shows that b2World::Step() was called from OnTimer().
closed account (4z0M4iN6)
CodeMonkey wrote:
The stack call shows that b2World::Step() was called from OnTimer().

Thank you for help. I didn't remember the correct order yet. Something I thought could be wrong, but I wasn't sure what.

Then JonB has to look at:

OnRefreshMsgLoop() + 0x44 bytes

Refreshing something could be exactly something like this. A half done refresh.
Last edited on
Maybe you should write @JonB

Thanks. I can see where he might think I was talking to you since you're obviously having problems with your box2d project. Perhaps you should avoid correcting things that don't need correcting, just for the sake of correcting.

For the record, b2World::Step is where the physics engine simulates a time step and updates all of the objects. The OP wouldn't have written any of the code therein. The root of the problem will be elsewhere.
closed account (4z0M4iN6)

I don't know nothing about box2d. I only can tell about DisableTimer().
And also I don't know, whether I'm right. But it's a good try, don't you think so?

I'am a very stubborn person, when I track a bug, I follow the track until the end and change my mind, whenever neccessary.

Until now I never had made a work around, but have tracked down every bug.
It's a hunt, like follow a wild game, change directions as does the game.
Last edited on

It's a bit redundant to offer such specific debugging advice if you have no idea what the code is about. If you're going to make assumptions purely based on the call stack and the error code, chances are you're going to miss quite a bit.
closed account (4z0M4iN6)

There is no reason yet to make any assumptions. Yet we have to try to make our catch and look at the code.

We are lucky, that it's only code. If it would have been a wild game, and you would have wanted to discuss about assumptions, whether it's here or not here, the game would have run away.
Last edited on
Er, Wow, hi everyone.
Thanks for your efforts!
@ Cire: I've not destroyed any bodies, just changed their set position from time to time.
Dadabe has the advantage of having seen my .cpp file.

I'd be happy to put it up here for general amusement (I'm very new to this) once I get home.

Personally, I now have an inclination that I may be trying to use objects that are in fact temporary, but what do I know!?

I'll put this up around 22:30 GMT.

closed account (4z0M4iN6)

Yes you gave me your source, but there was nothing to see.
I don't know nothing about box2d.
I didn't see anything of Set().
And also OnRefreshMsgLoop() wasn't in the source.
Tomorrow you can tell us, what it was. Maybe our hunt was useful for you.
We made a try. Now you do your try.
Whether you should use DisableTimer(), only you can know, maybe it's the situation I described, but you decide for another solution than DisableTimer(), maybe it's not inside OnRefreshMsgLoop, or simply you made another bug, we can't know. Who can know besides you?

What I showed, what would this be, if you wouldn't have made another bug.
Last edited on
@ dadabe:
I will certainly try what you suggested, although box2d makes no mention of this.
I will continue my hunt yes.
Thank you for the suggestion anyway.
When you say "there was nothing to see" do you mean my code looked ok?
JonB wrote:
Dadabe has the advantage of having seen my .cpp file.

He has the disadvantage of being completely new to C++ and he's demonstrated several misconceptions about the language on these boards. "Derp! You has a call stack! See! I didn't even see your code and I know what it is! Here is the solution!" doesn't really tend to make me think any more of his grasp of the language or programming in general for that matter, especially considering he's definitely not familiar with box2d and probably not familiar with your development environment (I know I'm not.)

I apologize for using the word derp.
closed account (4z0M4iN6)

I couldn't see something wrong.
But what could I've seen, when I don't know about box2d?
I saw code, which looked ok,
but which I couldn't understand, because I don't understand anything of box2d.

What I know: OnTimer happens in periodes. OnTimer randomly meets situations in your application. And when OnTimer meets in one moment a certain situation in your application, the error occures. This means, there exists an incompatibility between OnTimer and this situation, an undefined state. Because your program behaves well, when OnTimes don't meet this situation, there shouldn't be a bug in your application, only an incompatibility between OnTimer and this situation.

This has to be something, like data, which are used by ontimer and data you change. And when OnTimer happens during this change, when the change isn't done completly, OnTimer will have wrong data, which will not fit together. And then the error occurs.

You should look at the data, which are used by ontimer, and look, where you change them.

Or maybe better: If the function OnRefreshMsgLoop would be one of your functions and not some of Windows or box2d I would set all from begin to end between DisableTimer and EnableTimer.

But I didn't see such function in your code. Can you tell, what it is?

I couldn't find such function in Google.

It don't matter, where else you change data. The error occurs, when OpenTimer meets OnRefreshMsgLoop.

But, it needn't be neccessarily OnRefreshMsgLoop, which caused the error, it also could be somewhere else. Only you can know, which data are used by OnTimer.

I think, there is something wrong in our considerations.
Why should Step() cause the error?

Step	()	method	 
public function Step(dt:Number, velocityIterations:int, positionIterations:int):void

Take a time step. This performs collision detection, integration, and constraint solution.
	dt:Number — the amount of time to simulate, this should not vary.
	velocityIterations:int — for the velocity constraint solver.
	positionIterations:int — for the position constraint solver.
Validate	()	method	 

Number shouldn't be a problem, but the Iterations also shouldn't cause such an error, but it happens, this I don't understand.

It looks, like some code or data of this function would be destroyed. Code, I don't think so. But Step uses other data of the box2d class, otherwise it could do nothing. This means, something should have become wrong here:

m_allowSleep	property
public var m_allowSleep:Boolean
m_blockAllocator	property	 
public var m_blockAllocator:*
m_bodyCount	property	 
public var m_bodyCount:int
m_bodyDestroyList	property	 
public var m_bodyDestroyList:b2Body
m_bodyList	property	 
public var m_bodyList:b2Body
m_broadPhase	property	 
public var m_broadPhase:b2BroadPhase
m_contactCount	property	 
public var m_contactCount:int
m_contactList	property	 
public var m_contactList:b2Contact
m_contactManager	property	 
public var m_contactManager:b2ContactManager
m_filter	property	 
public var m_filter:b2CollisionFilter
m_gravity	property	 
public var m_gravity:b2Vec2
m_groundBody	property	 
public var m_groundBody:b2Body
m_jointCount	property	 
public var m_jointCount:int
m_jointList	property	 
public var m_jointList:b2Joint
m_listener	property	 
public var m_listener:b2WorldListener
m_positionIterationCount	property	 
public var m_positionIterationCount:int
m_stackAllocator	property	 
public var m_stackAllocator:*
s_enablePositionCorrection	property	 
public static var s_enablePositionCorrection:int = 1
s_enableWarmStarting	property	 
public static var s_enableWarmStarting:int = 1 

This means also, it need not neccessarily be an incompatibily between OnTimer and other situations.

Now it would be time to debug (debugger or output messages).

Could be a Pointer, maybe also a list, bool and int shouldn't be a problem.

I shouldn't believe too much, what others say and lead me astray.

Best would be, we would have the source code of step(), otherwise we have to debug.

If we have the source code, it should be the first line!

b2Timer stepTimer;

Such a line could only cause a stack overflow.
Is it a stack overflow? Don't know, I think, there should have been an error message for a stack overflow, when it would be one

Nothing helps, except debug!!!
Problem: random error.

Means: debugging by Logfile
print &steptimer in a Logfile

And when we get no new insight, wether it has something to do with the stack, then you have to explore more of your program by log messages.

I hate bugs, which costs much time.

I tried and finish this, because I don't want to debug your program.
I have also some work to do.

And such bugs, could be rather all, what could be imagined, like unfitting linker options for box2d, an unstable box2d version, who can know, also a compiler beta version.

It was a nice try, and often we have luck, but when we don't have luck, the work begins.

A good idea would be, post your listing for others, then they can try, wether it's stable on their system, when yes, it's your environment, when not it's your program.
Last edited on
closed account (4z0M4iN6)

This is the problem, if we use GNU. We can debug our programs, but debugging such GNU programs, we shouldn't do, it's not worth to do such a work. Then we should look for a program, which works better, besides you can find a bug in your code.
closed account (4z0M4iN6)
Hi, you all, seems I've got it.

I wanted to give up, but this isn't easy.

Because if I have a track, the track also has me.

And then I had the idea and thought, how stupid was me. Normally when I write code, I think of it. But I looked at your code, when I hadn't any idea, this was before I had the idea, which I told. And after I didn't think of the other idea, which I also should have thought about.

The solution should be the same 2 lines:


And I know now the exact fitting place.

The explanation is another one.

What, do you think, would happen, if a timer event elapses during OnTimer?

Then we would have a stack overflow.

So, you should insert these two lines in the function OnTimer - one at the begin, one at the end - I think, you know which one would be correct.
Then we would have a stack overflow.

stack overflow would give an error code of 0xC00000FD (and probably tell you that it was a stack overflow)
closed account (4z0M4iN6)
Yes I thought this also, you can read my former post, but some other memory might also overflow.

And which one first, don't matter. It matters only the error message.

So It has been to used!

Except we are sure, that the duration of OnTimer is short, relative to the timer elapse time, which I would doubt.
Last edited on
I would guess that somewhere else in your program, you have simply overwritten the b2World* used to perform the step, eg. by writing past the end of an array etc.

The best way to check would be to set a watch in the debugger to tell you when the value of the world pointer changes. It should never change for the duration of the world's lifetime.

If your debugger-fu is not so strong (or your debugger does not let you do that) then another way would be to record the address of the b2World when you first create it, and then every time before you call Step just check that the pointer is the same value as it was when it was created.

valgrind is also highly recommended for this kind of thing.
Last edited on
closed account (4z0M4iN6)
iforce2d wrote:
I would guess that somewhere else in your program, you have simply overwritten the b2World* used to perform the step, eg. by writing past the end of an array etc.

Yes, this is a good guess. We make a good guess, and then we try. After each try, we know more about the bug. And we should also try to gather more information about the bug. And the more, we know about the bug, the better will become our guesses and at last, we can catch it.

Now lets see, whether my guess hit. And if not, JosB has to use the debugger now or log messages.

If he don't know how to use, we should help.
Last edited on
closed account (4z0M4iN6)
CodeMonkey wrote:
stack overflow would give an error code of 0xC00000FD (and probably tell you that it was a stack overflow)

You are right about this, and also there isn't any evidence for a stack overflow caused by OnTimer, because then we should expect many recursive calls of OnTimer, but the error messages didn't show this.

What I did, I banned such thoughts, because they would have hindered me, to make a guess and a try. And compile and try is simple to do. Not simple to do is an exploration, why a stack overflow could lead to such error messages.

What we have to do:

win some information
make a good guess, what this could mean
ban thoughts, which hinder the guess
instead try and look the outcome

And this, you could think as a loop, but should think as a helix

Do you know about such a formula?
It's a very old formula.
People had known this formula long times ago.
Did you ever hear about these 4 elements:


The meaning was hidden in former times, because it wasn't a good idea in this times, to tell some truth.

And if you would think, this formula wouldn't work, then you only need to think, how well a motor works.

And the motor means, you don't need to imagine a helix, but could imagine some kind of rotation, which will cause some other kind of movement which means making a progress.

Oh, you know Nanny McPhee, and what she would have said?
This lesson you have learned!

The first lesson:
You wanted to discuss one dimensional.
You know, the other is wrong, this means: you are right.
But I could show you the 4th Dimension:

First look, then think, then look again. The second look will be a different one.

Because you had learned this, I could show you the third dimension.
Next time I can show you the second dimension.
And then you should have learned, what you should know:
You should know, how to learn.

Oh and this bug and the game look very funny.
It seems not only to be a game about destroying bodies.
It seems also to be something about minds.

Yes, your minds could have become a little bit dizzy by these rotations.

Maybe I should make your minds a little bit more dizzy?

This formula, which we had mentioned, was also expressed in words with four characters.

One word is Auto:

A: you can think of an activating energy (fire)
U: you can think of a potential energy (water)
T: you can think of a kind of explosion (air)
O: you can think of a solid material and a kind of rotation (earth)

Another word is JHWH.
This is one of the names for god.

JH means the adam and eve principle
W means the conjunction of adam and eve
H means, this conjunction results in a progressed eve in the next rotation ( You see, H is repeated? This means rotation! )

If you like, I could explain this a little bit more.

The adam principle is the male principle. And J is a very small Hebrew character, it looks like a semen. And this semen is an idea.

And the meaning of H is a vase and it's the female principle. You can think this vase an uterus and this uterus is your mind.

W means an idea had hit your mind and now you let the idea conjoin (W means conjoin, but you could also think of work) with your mind. You should let it work, instead of discuss it away. And the outcome is H, a progressed mind and can you think why? New ideas were born, your ideas in your mind got children, would you have ever thought this?

And what you can know now is: If you don't know, how to make a progress, god will help you.

I hope, you programmers are not such holy rollers, which would want to burn me now at the stake.

People normally don't know this basic formula (fire, water, air, earth), but they know formulas, which were deducted of this basic formula.

Salesmen know the formula AIDA.

Teachers know this formula: (sorry, I don't know exactly in english)

Encounter the theme
Develop the theme
Result of the theme

And what do you know about a discussion?

Conjunction (develop the idea for a solution of the conflict)

And there is much more to know about this.

These four steps are only the steps for getting ideas.
There are other steps for implementing ideas.

All together are the steps of software development and also of any development. These are the steps of creating works.

And because this is a very important knowledge, people had made something, that this knowledge will never be forgot.

We can find this knowledge in the names of the weekdays. The weekdays don't show the steps in the correct order.

The correct order you can find, when you assign the names to the hours of the days in the Babylonian order, starting with the sun for hour 0 on Sunday. And because a day has 24 hours and not 21 hours, the outcome will be the order of the weekdays.

Sorry, I don't have more time today, but can tell you more about this on Monday.
Last edited on
Pages: 123