Any one up for OSX work.


#218

And the latest run :slight_smile:

$ pview
Set here
SGB Constructed : 0x7213014
  current :0x5cbc698
set_default called
  new 0x5cbc698
SGB::get_default called: 0x5cbc698
default SG :0x7213014
SGB::get_default called: 0x5cbc698
default SGB:0x7213014
Known pipe types:
  osxGraphicsPipe
(all display modules loaded.)
a:0x1e29daf4:3
b:1
c:0x27d6cc:3
d:0x27d1a4:16
1:0x27d6cc
2:0
SGB::get_default called: 0x5cbc698
3:0
Bus error

#219

The address of the pointer is the same. Nothing else sets the variable. Still, suddenly it becomes NULL.
So unless Panda calls ((int)0x5cbc698) = 0; somewhere this is impossible in my eyes. I’m lost here.


#220

Ah, I think I understand what’s going on. This is a static-init ordering problem.

This is one of those real nasty C++ problems; and one that I’m quite familiar with (we’ve been fighting it in various forms for years). It’s also one of the reasons I’m not at all a fan of doing a lot of stuff automatically in static init, but one of our early Panda developers thought this was a swell idea and started us down this path, and it’s too late to go back now.

Static init is a concept that was introduced with the development of C++ and its constructors. Originally, when all compiled programs were written in C or some similar non-object-oriented language, there wasn’t much code that ran before main() was called; just some startup stuff hardcoded into the system runtime libraries. C allows you to define global or “static” variables outside of any function scope, and even give them initial values, like this:

int x = 10;
int main() {
  ...
}

which means that at the time main() is called, x already exists and has the value 10. This was implemented by preloading a memory image that already had the right bits in the right place when it was loaded from disk; no code was necessary to run before main in order to assign 10 to x.

But, now introduce C++ and its constructors. Now you can declare an object outside of main that has a constructor. According to C++ semantics, that constructor has to be called to initialize that object, and thus you now have user code that is running before main:

class Thing {
  Thing() { cerr << "initializing\n"; }
};
Thing x;
int main() {
  cerr << "running main\n";
  return 0;
};

This caused a sea change in system library support, because suddenly the system runtime loader has to support calling user code automatically when a program is started, or even when a .so is loaded in at runtime.

But anyway. Part of Panda’s low-level design takes advantage of these static initializers to call all sorts of setup function when the libraries are loaded. init_libpgraphnodes() is one of those functions, and one of the things it calls is ShaderGenerator::set_default(new ShaderGenerator()). This gets called at static init time, by virtue of a class object with a constructor, and so it is supposed to be called automatically when libpgraphnodes.so gets loaded into the running program. So, we’re supposed to be guaranteed that the ShaderGenerator already has a default value set by the time we start running.

But wait! We also have a static constuctor in libpgraph.so. It looks like this:

PT(ShaderGeneratorBase) ShaderGeneratorBase::_default_generator;

Don’t see the static constructor? It’s hard to see, isn’t it? Welcome to the joys of C++, where code can be hidden from the programmer. In fact, there’s a default constructor for the class PT(ShaderGeneratorBase), and the default constructor’s job is to initialize its pointer to NULL.

So, as long as libpgraph.so’s static constructors are called before the ones in libpgraphnodes.so, then everything is good: the default constructor for _default_generator will be called, ensuring that pointer is NULL. Then the static constructors in libpgraphnodes.so will be called, which will call set_default(), reassigning the pointer to a valid value. But, if the static constructors happen to get called in the opposite order, we have a terrible situation: the set_default() will be called first, assigning the pointer to a valid value, and then the default constructor will be called later, reassigning the pointer to NULL! That’s certainly what’s happening here.

Unfortunately, the system does not guarantee any ordering of static init constructors between different .so’s. It’s absolutely unpredictable. So on one system, it might call these in the correct order, and on another system, it might call them in the incorrect order. The ordering might even change from one day to the next.

So, basically, I introduced this bug when I split up libpgraph.so and libpgraphnodes.so, because in doing so I introduced a nondeterministic behavior between these static initializers. But because C++ tries so hard to make things automatic, the bug is extremely hard to see until it bites you, and you spend days isolating it down to discover that a pointer is getting reset to NULL after you had thought it was properly set.

I’ll fix the bug now. It’s easy to fix, by replacing the PT(ShaderGeneratorBase) with an ordinary ShaderGeneratorBase * pointer. The reason this will fix the problem is that an ordinary pointer doesn’t have a constructor, so its default value will be set to NULL by preloading the memory image, and so there’s no longer an ordering issue between static initializers. (I’ll also have to explicitly manage the reference counts in set_default() to compensate for this change, but that’s not so bad.)

My apologies for the long trip down a dark corridor I caused you guys.

David


#221

It was in this moment, when all hope had faded, that Isild-- oh, wrong line :slight_smile:

But seriously, thanks a lot! You’re the best :slight_smile: Also thanks for the clear explanation, next time something like this occurs, I’ll know what actually happens.

We’ll know for sure when compiling has finished, but I’d bet my bottom dollar on it.


#222

Marvellous ! :slight_smile: Thanks for the explanation.

I look forward too see the end of the next build :slight_smile:


#223

DMG is updated. Let me know if it works.


#224

WOHOO :slight_smile:

setShaderAuto() works :slight_smile:

Thanks a bundle ! :slight_smile:


#225

Great! And thanks to you for your patience and for reporting this bug in time :slight_smile:

I’m aware of the syntax errors in the cartoon shader and will get that fixed soon.
Are the problems with the “not powerful enough” bug fixed, too?


#226

Yes, for all the samples but the Cartoon-Shader/Tut-Cartoon-Shader-Basic

Strangely enough, the advanced one works while the basic doesn’t…


#227

Hmm, sounds like a parasite-buffer-vs-real-buffer problem.
If you want, could you try out the new DMG and see if it works?
I’m pretty sure it will work now. Plus, it prints out some debug information (marked with “DEBUGINFO”)


#228

Tested, and works :smiley:

Thanks!


#229

Really? Sweet :slight_smile: What does it print out?


#230
$ python ./Tut-Cartoon-Basic.py 
DirectStart: Starting the game.
Known pipe types:
  osxGraphicsPipe
(all display modules loaded.)
:util(warning): Adjusting global clock's real time by 0.614944 seconds.
DEBUGINFO: GLGraphicsBuffer: 1
:util(warning): Adjusting global clock's real time by -1.00788 seconds.
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (33) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (33) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (33) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (36) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (36) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (36) : error C0501: type name expected at token ")"
:gobj(error): created-shader: (36) : warning C7011: implicit cast from "float4" to "float3"
:gobj(error): created-shader: (36) : error C0000: syntax error, unexpected ')', expecting ';' or ',' at token ")"
:gobj(error): created-shader: (36) : error C0501: type name expected at token ")"

The important line here being: DEBUGINFO: GLGraphicsBuffer: 1
and everything after it noise from a incorrectly written shader ?

(additional edit) Sorry for the late answer, I was interrupted, and thought I had pushed “submit” :slight_smile:

I have tried the other demos (those that aren’t specifically announced as shader demos) and one of them worries me.

The firefly demo (which used to crash badly) doesn’t crash anymore.
But there’s an error which I havn’t traced the source for yet:
$ python ./Tut-Fireflies.py
DirectStart: Starting the game.
Known pipe types:
osxGraphicsPipe
(all display modules loaded.)
:util(warning): Adjusting global clock’s real time by 0.776161 seconds.
DEBUGINFO: GLGraphicsBuffer: 1
DEBUGINFO: GLGraphicsBuffer: 1
:util(warning): Adjusting global clock’s real time by -58.1736 seconds.
:display:gsg:glgsg(error): Could not load Cg fragment program:/Volumes/Diburnium/Users/thor/Downloads/panda3d-1.5.4/samples/Fireflies/model.sha (arbfp1 Error on line 2: unrecognised option (hint: ‘ATI_draw_buffers’))

Now, since I have an nVidia graphics card, I don’t know why it would want to call the ATI_draw_buffers function (if any such exists).

The demo runs, so to speak, but since it’s using dual buffers, and the shader isn’t running, it’s output is nil.

Then, adding to the conveyor belt :slight_smile: Have you done any audio work on Panda ? The ffmpeg port seems to think that I’m calling the PlayStation audio functions or something, and as such, it’s rather random if and when the audio works - or not (which is more common).


#231

Another strange one:

In the Motion-Trails demo, the background should be something, but is actually a partially overlapping 2-d image of bits and pieces that have at some time been in my display buffer…

Running the demo today displays parts of a presentation I was working on yesterday, partials from a panda project I was working on yesterday, a black frame white boxes…

Very strange… (not that it affects me directly, not yet at least, but I thought you’d want to know)


#232

I’ve already fixed the bug with the syntax error, and have recently checked it into CVS (but have not updated the DMG yet, I think.)

I don’t really know about the ATI_draw_buffers thing. Can you try and execute this command:

glxinfo | grep -i ati_draw_buffers

I don’t have a clue about why ffmpeg behaves oddly. Note that you can also switch to OpenAL by editing the Config.prc file and replacing “p3fmod_audio” with “p3openal_audio”. I have no clue how stable the OpenAL implementation on OSX is, though.


#233

The outpu from glxinfo yields nothing, so I grepped for “ati” with the following result:

$ glxinfo | grep -i ati
    GLX_ARB_multisample, GLX_EXT_visual_info, GLX_EXT_visual_rating, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_allocate_memory, 
    GLX_EXT_visual_rating
OpenGL vendor string: NVIDIA Corporation
    GL_EXT_blend_equation_separate, GL_EXT_texture_mirror_clamp, 
    GL_APPLE_float_pixels, GL_ATI_texture_float, GL_ARB_texture_float, 
    GL_NV_vertex_program3, GL_ATI_texture_mirror_once, 
    GL_ATI_texture_env_combine3, GL_ATI_separate_stencil, 

I ran a simple project I have on ffmpeg. Figure that it decides to (mostly) work now :slight_smile: (it doesn’t all that well on my laptop)

The error it spits out is:
:audio(error): _channel->stop(): An invalid object handle was used.

If I get that error, the subsequent sound won’t be played (usually, although finding a pattern isn’t that easy…)

But if I switch to OpenAL, life gets more… umm… interesting :slight_smile:

$ python ./factory.py 
DirectStart: Starting the game.
Known pipe types:
  osxGraphicsPipe
(all display modules loaded.)
:util(warning): Adjusting global clock's real time by 0.379033 seconds.
:util(warning): Adjusting global clock's real time by -2.01429 seconds.
:interval(error): Event 2 not on active list.
Assertion failed: false at line 898 of direct/src/interval/cMetaInterval.cxx
Traceback (most recent call last):
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/showbase/ShowBase.py", line 1521, in __ivalLoop
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/interval/IntervalManager.py", line 95, in step
AssertionError: false at line 898 of direct/src/interval/cMetaInterval.cxx
:task(error): Exception occurred in PythonTask ivalLoop
Traceback (most recent call last):
  File "./factory.py", line 12, in <module>
    run()
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/showbase/ShowBase.py", line 2418, in run
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/task/TaskNew.py", line 471, in run
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/task/TaskNew.py", line 429, in step
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/showbase/ShowBase.py", line 1521, in __ivalLoop
  File "Panda3D-tpl-rw/Panda3D/1.6.0/lib/direct/src/interval/IntervalManager.py", line 95, in step
AssertionError: false at line 898 of direct/src/interval/cMetaInterval.cxx

So, apparently, OpenAL isn’t the way to go - here… :slight_smile:


#234

Every time you say that I have this recurring fantasy where I tell my good friend Steve Jobs to send you a computer.


#235

Ok, back to the audio issue - if anyone has an idea :slight_smile:

These are the errors that generally occur (this is from a short run of a modified version of “AdvancedRalph”)

:util(warning): Adjusting global clock's real time by 0.478241 seconds.
:audio(error): createSound(/Applications/Panda3D/1.6.0/models/audio/sfx/GUI_rollover.wav): End of file unexpectedly reached while trying to read essential data (truncated data?). 
:audio(error): createSound (blank): Not enough memory or resources. 
:audio(error): _sound->getDefaults(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): createSound(/Applications/Panda3D/1.6.0/models/audio/sfx/GUI_click.wav): End of file unexpectedly reached while trying to read essential data (truncated data?). 
:audio(error): createSound (blank): Not enough memory or resources. 
:audio(error): _sound->getDefaults(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:util(warning): Adjusting global clock's real time by -8.74525 seconds.
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _system->playSound(): Not enough memory or resources. 
:audio(error): _channel->setCallback(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPosition(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _sound->getMode(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 
:audio(error): _channel->setPaused(): PS2 only.  fmodex.irx failed to initialize.  This is most likely because you forgot to load it. 

The system uses ffmpeg (since OpenAL doesn’t work at all on OS X)


#236

I kinda hate to resurrect such a old thread, but it does apply.

I am trying out panda on mac tiger and trying ./configure osx, but it stops very soon complaining that it can’t find install-sh,and ‘.’ is a path it claims to not find it in, and im sure it IS there.

Is this a weird mac path issue or some ENV path issue or something I"ve yet to setup ?

thx anyone
lee


#237

I suggest you use the makepanda script to compile Panda3D rather than ppremake. It’s a lot easier to use. This thread dates back to when makepanda didn’t support OSX yet.