mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
314 stars 97 forks source link

OSError: exception: access violation reading 0x0000000000000000 in wrapper.py #73

Open pragma37 opened 2 years ago

pragma37 commented 2 years ago

Hi! I use PyOpenGL in the render engine I develop.

I get this exception when I call glClear or glClearBuffer.

  File "C:\DEV\Malt\BlenderMalt\.MaltPath\Malt\.Dependencies-39\OpenGL\latebind.py", line 43, in __call__
    return self._finalCall( *args, **named )
  File "C:\DEV\Malt\BlenderMalt\.MaltPath\Malt\.Dependencies-39\OpenGL\wrapper.py", line 693, in wrapperCall
    result = wrappedOperation( *cArguments )
OSError: exception: access violation reading 0x0000000000000000

If I never call them, everything else seems to work (render is broken, obviously). But if I catch the exception, further calls to other OpenGL functions (including swapping buffers with pyglfw or sdl2py).

These functions seem to be _NullFunctionPointer instances. Any idea how this might happen?

screenshot

I can reproduce this issue almost every time on my Windows 10, AMD laptop. (I tested on different driver versions) The user that reported this issue initially uses Windows 10 and AMD hardware too: https://github.com/bnpr/Malt/issues/227

On my Nvidia desktop, everything works without issues. It worked fine on AMD hardware in the past, too. Small samples (just opening a window and clearing/swapping buffers) works fine.

I leave the log file generated by my renderer, just in case: malt 2022-01-30(18-49).log

pragma37 commented 2 years ago

Seems like this was caused by an incorrect usage of occlusion queries. Anyway, is this the intended behavior? Can an incorrect usage of the OpenGL API cause function pointers to become null?

mcfletch commented 1 year ago

That doesn't look like a function pointer going null. Looks more like a pointer to a vector (e.g. the colour) having been garbage collected by the time the call is actually applied to the buffer. A null function pointer would produce a NullFunctionPointer exception when attempting to finish the call. You could verify it by storing the color somewhere (as a numpy array or other pointer-compatible form).