Mysterious FreeBSD Crash

I’m running into a segmentation fault (11) with pview on FreeBSD. It appears to be in this line of graphicsPipeSelection.cxx:

      PT(GraphicsPipe) pipe = (*ptype._constructor)();

When I invoke this constructor inside add_pipe_type it works good, no crash.
Maybe someone has more ideas how I can further investigate the issue?

Hmm, is it possible the .so has been automatically unloaded for some reason by the time make_pipe() is called? Or is it possible that you have invalid data in the _pipe_types set for some reason–are you sure the _constructor pointer that crashes in make_pipe() is the same as the one that works in add_pipe()?


I’ve printed out the constructor pointer in config_glxdisplay.cxx, add_pipe_type and when it’s about to be invoked, In all cases it shows “1”. I’ve tried to put a & before the function pointer, but it makes no difference.
When I invoke the constructor within config_glxdisplay.cxx or within add_pipe_type it appears to work.

Not sure how I can check about the .so being unloaded - but I do know that the end of load_named_module is never reached.

EDIT: Wait, you were right! unload_dso is called before it gets the chance to create the pipe, in this code:

  if (pipe_type_index == 0) {
    // The recommendation function had no advice, weird.
    return TypeHandle::none();

Just a wild guess - could it be a static-init issue, that the TypeHandle of the pipe is initialized after init_glxdisplay is called?

Okay, I think I found what’s causing it. The file pandagl.cxx only returns the glx class type index if IS_LINUX is defined, and obviously it isn’t. I’ll replace it with HAVE_GLX.

Thanks for your help!

EDIT: yep, everything appears to work fine now. I’ve also added an #error message to pandagl.cxx so that it won’t return 0 and this weird crash won’t bother anyone anymore.
Everything works great here in freebsd, yay!