What could cause opengl to hang on a syscall when the depth bit is cleared?

I’ll give the snippet of code I’m working with:

#if 1
	pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_IGNORE_ERRORS, false );
#endif

#if 0
	gfxBits = pawvfxWhatBits
		( Vfx, PAWVFX_O_COLOR_BUFFER | PAWVFX_O_DEPTH_BUFFER );
#else
	gfxBits = pawvfxWhatBits( Vfx, PAWVFX_O_COLOR_BUFFER );
#endif

	aid = PawvfxMakeGfxApp( Vfx );
	App = PawSeekUD( aid );

	pawwinDeclIntegerHint( Wfx, PAWWIN_H_INTEGER_DEPTH_BITS, 24 );
	pawwinShow( Win, true );
	pawvfxMoveCtx( Vfx, 0, 0, winBoxW, winBoxW );
	if ( App )
	{
		while ( pawwinKeep( Win ) )
		{
			pawapi_bindVfxApp( Vfx, NULL );
			pawwfxPollAll( Wfx );
			if ( pawwfxReadKey( Win, PAWKEY_ANSI_ESC ) )
			{
				pawwinShut( Win, true );
				continue;
			}
			pawvfxColours( Vfx, 0, 0, 0, 0 );
			pawgfxZeroBits( Vfx, gfxBits );

			numlen = pawu2s( &numstr, numint, PAW_BASE10 );
			pawtcsResizen( winText, numstr.str, numlen );
			numint = (numint + 1) * numlen;
			pawwinDeclText( Win, winText );
			pawwinSwapBuffers( Win );
		}
	}

	pawDropID(aid);
	PawDropID(wid);
	Win = NULL;
	wid = -1;
	return 0;

Without the depth bit being cleared all works dandy in this initial blank context, as soon as I try to clear the bit it hangs upon trying to swap the buffers (using glfw & glew under the hood of these wrappers atm btw), any ideas as to what I should look for or enable (btw depth test is enabled as soon as the initialisation of glew succeeds), btw Vfx & Wfx are just hooks for the libraries wrapping glfw & glew, the intent is that I can just hook the wrappers and have them deal with the source APIs while the top level code get’s a consistent api to work with regardless of whether opengl, vulkan, x11, wayland, etc are in use.

Did a fair bit of editing to get the related calls into one function to encourage someone to help, again they just wrap to the relative glfw & opengl calls under the hood (pawvfxWhatBits is an exception since it remaps the bits paw offers to the underlying api’s bits for cross-api speed, in this case GL_COLOR_BUFFER_BIT etc)

pawd test_wrappers()
{
	pawu numint = 0, gfxBits = 0;
	pawWFX	Wfx = libWfx.api;
	pawVFX	Vfx = libVfx.api;
	pawVFR	App = NULL;
	pawd	aid = -1;
	pawlsu	numstr = INIT_pawlsu;
	pawd	numlen = 0;

	if ( !Wfx || !Vfx || !winText )
	{
		if ( !Wfx ) pawPrints( "Need window api hook!\n" );
		if ( !Vfx ) pawPrints("Need graphics api hook!\n");
		if ( !winText ) pawPrints("Need initial window title!\n");
		return -1;
	}

	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXAPI, PAWWFX_E_CTXAPI_NATIVE );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI, PAWWFX_E_GFXAPI_OPENGL );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI_PROFILE, PAWWFX_E_GFXAPI_PROFILE_CORE );
	pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_GFXAPI_FW_SAFE, true );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MAJOR, 4 );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MINOR, 3 );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_SAMPLES, 4 );
#if 0
	pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_IGNORE_ERRORS, false );
#endif
	pawwinDeclIntegerHint( Wfx, PAWWIN_H_INTEGER_DEPTH_BITS, 32 );

	wid = PawwinCreate( Wfx, NULL, NULL, winBoxW, winBoxH, winText );
	Win = PawSeekUD( wid );
	if ( !Win )
	{
		pawPrints("Failed to create window!\n");
		return -1;
	}

	pawwinBindContext( Win );
	if ( pawvfxInitApi( Vfx, true ) != 0 )
	{
		pawPrints("Failed to initiliase GFX API!\n");
		return -1;
	}

	pawvfxInitDbg( Vfx, true, debugVfxCB, NULL );
	pawvfxTestDepth( Vfx, true );
	pawvfxMaskDepth( Vfx, true );

	pawPrints("Launching Graphics Tests...\n");


#if 1
	gfxBits = pawvfxWhatBits
		( Vfx, PAWVFX_O_COLOR_BUFFER | PAWVFX_O_DEPTH_BUFFER );
#else
	gfxBits = pawvfxWhatBits( Vfx, PAWVFX_O_COLOR_BUFFER );
#endif

	aid = PawvfxMakeGfxApp( Vfx );
	App = PawSeekUD( aid );


	pawwinShow( Win, true );
	pawvfxMoveCtx( Vfx, 0, 0, winBoxW, winBoxW );
	if ( App )
	{
		while ( pawwinKeep( Win ) )
		{
			pawvfxBindGfxApp( Vfx, NULL );
			pawwfxPollAll( Wfx );
			if ( pawwfxReadKey( Win, PAWKEY_ANSI_ESC ) )
			{
				pawwinShut( Win, true );
				continue;
			}

			pawvfxBaseColor( Vfx, 0, 0, 0, 0 );
			pawgfxZeroBits( Vfx, gfxBits );
			pawvfxBaseDepth( Vfx, 0.0 );


			numlen = pawu2s( &numstr, numint, PAW_BASE10 );
			pawtcsResizen( winText, numstr.str, numlen );
			numint = (numint + 1) * numlen;
			pawwinDeclText( Win, winText );
			pawwinSwapBuffers( Win );
		}
	}

	pawDropID(aid);
	PawDropID(wid);
	Win = NULL;
	wid = -1;
	return 0;
}

Edit: Forgot to rename a function for more intuitive understanding of it, applied the change here also, for the unfamiliar you can check the old name via the comment history

I have no idea what any of your code does.

Seriously.

You need to stop showing your wrapper calls and show the actual OpenGL calls that happen behind them. Because your wrapper means absolutely nothing to anybody that’s not you, you could have any kind of code there, and the rest of us have absolutely no way of knowing what it’s doing.

1 Like

Alright here’s the edited version:

pawd test_wrappers()
{
	pawu numint = 0, gfxBits = 0;
	pawWFX	Wfx = libWfx.api;
	pawVFX	Vfx = libVfx.api;
	pawVFR	App = NULL;
	pawd	aid = -1;
	pawlsu	numstr = INIT_pawlsu;
	pawd	numlen = 0;

	if ( !Wfx || !Vfx || !winText )
	{
		if ( !Wfx ) pawPrints( "Need window api hook!\n" );
		if ( !Vfx ) pawPrints("Need graphics api hook!\n");
		if ( !winText ) pawPrints("Need initial window title!\n");
		return -1;
	}

	// glfwWindowHint
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXAPI, PAWWFX_E_CTXAPI_NATIVE );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI, PAWWFX_E_GFXAPI_OPENGL );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_GFXAPI_PROFILE, PAWWFX_E_GFXAPI_PROFILE_CORE );
	// glfwWindowHint
	pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_GFXAPI_FW_SAFE, true );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MAJOR, 4 );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_CTXVER_MINOR, 3 );
	pawwfxDeclIntegerHint( Wfx, PAWWFX_H_INTEGER_SAMPLES, 4 );
#if 0
	pawwfxDeclBooleanHint( Wfx, PAWWFX_H_BOOLEAN_IGNORE_ERRORS, false );
#endif
	// glfwWindowHint
	pawwinDeclIntegerHint( Wfx, PAWWIN_H_INTEGER_DEPTH_BITS, 32 );

	// gflwCreateWindow
	wid = PawwinCreate( Wfx, NULL, NULL, winBoxW, winBoxH, winText );
	Win = PawSeekUD( wid );
	if ( !Win )
	{
		pawPrints("Failed to create window!\n");
		return -1;
	}

	// glfwMakeContextCurrent
	pawwinBindContext( Win );
	if ( pawvfxInitApi( Vfx, true ) != 0 )
	{
		pawPrints("Failed to initiliase GFX API!\n");
		return -1;
	}

	pawvfxInitDbg( Vfx, true, debugVfxCB, NULL );
	// glEnable( GL_DEPTH_TEST )
	pawvfxTestDepth( Vfx, true );
	// glDepthMask
	pawvfxMaskDepth( Vfx, true );

	pawPrints("Launching Graphics Tests...\n");

	// Get GL_COLOR_BUFFER_BIT etc
#if 1
	gfxBits = pawvfxWhatBits
		( Vfx, PAWVFX_O_COLOR_BUFFER | PAWVFX_O_DEPTH_BUFFER );
#else
	gfxBits = pawvfxWhatBits( Vfx, PAWVFX_O_COLOR_BUFFER );
#endif

	aid = PawvfxMakeGfxApp( Vfx );
	App = PawSeekUD( aid );


	pawwinShow( Win, true );
	// glViewport
	pawvfxMoveCtx( Vfx, 0, 0, winBoxW, winBoxW );
	if ( App )
	{
		// glfwShouldWindowClose
		while ( pawwinKeep( Win ) )
		{
			// glUseProgram
			pawvfxBindGfxApp( Vfx, NULL );
			// glfwPollEvents
			pawwfxPollAll( Wfx );
			// glfwGetKey
			if ( pawwfxReadKey( Win, PAWKEY_ANSI_ESC ) )
			{
				pawwinShut( Win, true );
				continue;
			}
			// glClearColor
			pawvfxBaseColor( Vfx, 0, 0, 0, 0 );
			// glClear
			pawgfxZeroBits( Vfx, gfxBits );
			// glClearDepth
			pawvfxBaseDepth( Vfx, 0.0 );


			numlen = pawu2s( &numstr, numint, PAW_BASE10 );
			pawtcsResizen( winText, numstr.str, numlen );
			numint = (numint + 1) * numlen;
			pawwinDeclText( Win, winText );
			// glfwSwapBuffers
			pawwinSwapBuffers( Win );
		}
	}

	pawDropID(aid);
	PawDropID(wid);
	Win = NULL;
	wid = -1;
	return 0;
}

Seems it didn’t like not having any vertices to send, stopped hanging after I finally finished adding in the wrappers for the buffers symbols etc and created the hooks, didn’t actually send anything so I’m betting it had left over internal hooks from the creation process, didn’t create a vertexattrarray though (btw that thing is SEVERELY badly named, config is better as it’s more intuitive about it’s usage)

I stand corrected, it just stopped hanging for a different reason, I had bugs, having sorted them and just finished implementing the logging feature I now have a pure opengl call sequence to give you, still got the glfw logger to set up but for now this should be of use:

Hooked libpawwfx-glfw.so
Hooked libglfw.so
Hooked libpawvfx-glew.so
Hooked libGLEW.so
glewInit()
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
Launching Graphics Tests...
glCreateShader( GL_VERTEX_SHADER );
glShaderSource( 1, 1, [0x559A2A5F58D8], [2977] );
glCompileShader( 1 );
glGetShaderiv( 1, GL_COMPILE_STATUS, 0x7FFD30525874 );
glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( 2, 1, [0x559A2A5D1018], [2986] );
glCompileShader( 2 );
glGetShaderiv( 2, GL_COMPILE_STATUS, 0x7FFD30525874 );
glCreateProgram();
glGenVertexArrays( 1, 0x559A2AC88160 );
glGenBuffers( 1, 0x559A2AC89948 );
glBindBuffer( GL_ARRAY_BUFFER, 1 );
glBufferData( GL_ARRAY_BUFFER, 512, 0x559A2A2A5C08, GL_STATIC_DRAW );
glAttachShader( 3, 1 )
glAttachShader( 3, 2 )
glLinkProgram( 3 );
glGetProgramiv( 3, GL_LINK_STATUS, 0x7FFD305258AC );
glDetachShader( 3, 1 );
glDetachShader( 3, 2 );
glViewport( 0, 0, 640, 640 );
glValidateProgram( 3 );
glGetProgramiv( 3, GL_VALIDATE_STATUS, 0x7FFD305258AC );
glGetAttribLocation( 3, "s" );
================================================================================
                                    Draw Loop
================================================================================
glUseProgram( 3 );
glBindVertexArray( 1 );
glBindBuffer( GL_ARRAY_BUFFER, 1 );
glEnableVertexArrayAttrib( 1, 0 );
glClearColor( 0.00, 0.00, 0.00, 0.00 );
glClear( 0x00004100 );
glClearDepth( 0.00 );
glDrawArrays( GL_POINTS, 0, 0 );
Program was forcefully terminated
Compilation finished successfully.

Edit: Just realised I forgot to print what flags are cleared, added those in after correcting the log output

Edit 2: Spotted a few oddities in the output where names that where supposed to be looked up from arrays were turning out to be in their hexadecimal format, altered the source macros that generated the strings and the expected names popped up, updated the above so the more meaningful names show up.

Finally finished adding call logging for the glfw also, here’s the final result:

Hooked libpawwfx-glfw.so
Hooked libglfw.so
glfwInit();
Hooked libpawvfx-glew.so
Hooked libGLEW.so
glfwWindowHint( GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API );
glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
glfwWindowHint( GLFW_SAMPLES, 4 );
glfwWindowHint( GLFW_DEPTH_BITS, 32 );
glfwCreateWindow( 640, 480, "PAW memory, window & graphics tests", 0x0, 0x0 );
glfwSetWindowUserPointer( 0x5580EECC11F0, 0x5580EECC0270 );
glfwMakeContextCurrent( 0x5580EECC11F0 );
glewInit()
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
Launching Graphics Tests...
glCreateShader( GL_VERTEX_SHADER );
glShaderSource( 1, 1, [0x5580EF29DF48], [2977] );
glCompileShader( 1 );
glGetShaderiv( 1, GL_COMPILE_STATUS, 0x7FFC9462B0F4 );
glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( 2, 1, [0x5580EF279688], [2986] );
glCompileShader( 2 );
glGetShaderiv( 2, GL_COMPILE_STATUS, 0x7FFC9462B0F4 );
glCreateProgram();
glGenVertexArrays( 1, 0x5580EF930690 );
glGenBuffers( 1, 0x5580EF931E78 );
glBindBuffer( GL_ARRAY_BUFFER, 1 );
glBufferData( GL_ARRAY_BUFFER, 512, 0x5580EEC7DA78, GL_STATIC_DRAW );
glfwShowWindow( 0x5580EECC11F0 )
glAttachShader( 3, 1 );
glAttachShader( 3, 2 );
glLinkProgram( 3 );
glGetProgramiv( 3, GL_LINK_STATUS, 0x7FFC9462B12C );
glDetachShader( 3, 1 );
glDetachShader( 3, 2 );
glViewport( 0, 0, 640, 640 );
glValidateProgram( 3 );
glGetProgramiv( 3, GL_VALIDATE_STATUS, 0x7FFC9462B12C );
glGetAttribLocation( 3, "NulPoint" );
================================================================================
                                    Draw Loop
================================================================================
glfwGetKey( 0x5580EECC11F0, GLFW_KEY_ESCAPE );
glUseProgram( 3 );
glBindVertexArray( 1 );
glBindBuffer( GL_ARRAY_BUFFER, 1 );
glEnableVertexArrayAttrib( 1, 0 );
glClearColor( 0.00, 0.00, 0.00, 0.00 );
glClear( 0x00004100 );
glClearDepth( 0.00 );
glDrawArrays( GL_POINTS, 0, 0 );
glfwSetWindowTitle( 0x5580EECC11F0, "0" );
glfwSwapBuffers( 0x5580EECC11F0 );
Program was forcefully terminated
Compilation finished successfully.

Still getting a hanging window so I’m not sure what’s going wrong

Edit: Took me long enough to notice glfw was not being notified of the expected api, fixing that didn’t change the hanging problem though :expressionless:

I suspect this call. COUNT param = 0 should not be problem, but I found out that some drivers don’t like that. That call draws nothing anyway.