Thread: A segfault I'm unable to locate the source of

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735

    A segfault I'm unable to locate the source of

    I'm struggling to identify what is causing the segfault found via the callstack show below, all the relevant functions that you might want to see the contents of are in the files below, the code below is from test/extra/main.c. Can't think of anything else to mention at the moment so I'm just hoping for either a fix or some ideas on where to look for the source of the problem.

    Files of interest: test/extra/main.c src/extra/viewfx/glfw/vfxwai.c src/extra/viewfx/glfw/vfxwin.c
    Files * 05e8b876ddd1f660802a003982b9ab536834ea5d * Lee Shallis / Dragonbuilder * GitLab
    Function I cannot debug:
    GLFW: Initialization, version and error reference
    Code:
    #include "main.h"
    
    dint changeColors( APP *app ) { (void)app; return 0; }
    void void_shared( APP *app )
    {
    	dint i;
    	VoidVfxCfgsVoids( app );
    	memset( app->SharedVfxCfgs, 0, sizeof(VFXCFG*) * SHARED_BUFFER_COUNT );
    	VoidVfxVarsVoids( app );
    	memset( app->SharedVfxVars, 0, sizeof(VFXVAR*) * SHARED_BUFFER_COUNT );
    	VoidVfxBufsVoids( app );
    	memset( app->SharedVfxBufs, 0, sizeof(VFXBUF*) * SHARED_BUFFER_COUNT );
    	for ( i = SHARED_BUFFER_COUNT; i > 0; --i )
    		VoidBuffer( app, &(app->SharedBuffers[--i]) );
    }
    
    int main( int argc, char *argv[] )
    {
    	APP app = {0};
    	setbuf( stdout, NULL );
    	if ( app.err )
    	{
    		PRINT_ERRNO( stdout, app.err );
    		return EXIT_FAILURE;
    	}
    
    	do
    	{
    		achs hint = NULL;
    		dint i, one, two, winX, winY, winH, winW;
    
    		app.wai.name = "glfw";
    		app.vai.name = "gl";
    
    		one = MakeAchs( &app, &(app.wai.File), 0 );
    		two = MakeAchs( &app, &(app.vai.File), 0 );
    
    		if ( one || two )
    		{
    			if ( one )
    				PRINT_ERRNO( stdout, one );
    			if ( two )
    				PRINT_ERRNO( stdout, two );
    			app.err = one ? one : two;
    			break;
    		}
    
    		one = InitAchs( &app, app.wai.File, "" );
    		two = InitAchs( &app, app.vai.File, "" );
    
    		if ( one || two )
    		{
    			if ( one )
    				PRINT_ERRNO( stdout, one );
    			if ( two )
    				PRINT_ERRNO( stdout, two );
    			app.err = one ? one : two;
    			break;
    		}
    
    		for ( i = 0; i < argc; ++i )
    		{
    			smax wai_diff = 0, vai_diff = 0;
    
    			if ( argv[i][0] != '-' )
    				continue;
    
    			hint = achschar( argv[i], '=' );
    
    			if ( hint )
    			{
    				*((ach*)hint) = 0;
    				wai_diff = achsdiff( argv[i], "--wai" );
    				vai_diff = achsdiff( argv[i], "--vai" );
    				*((ach*)hint) = '=';
    			}
    			else
    			{
    				hint = argv[++i];
    				wai_diff = achsdiff( argv[i], "--wai" );
    				vai_diff = achsdiff( argv[i], "--vai" );
    			}
    
    			if ( hint && wai_diff == 0 )
    				app.wai.name = hint;
    
    			if ( hint && vai_diff == 0 )
    				app.vai.name = hint;
    		}
    
    		one = growAchsArrayf
    		(
    			&app, app.wai.File, "%s%s%s%s",
    			DLL_PFX, "vfx", app.wai.name, EXT_PFX DLL_SFX
    		);
    
    		two = growAchsArrayf
    		(
    			&app, app.vai.File, "%s%s%s%s",
    			DLL_PFX, "vfx", app.vai.name, EXT_PFX DLL_SFX
    		);
    
    		if ( one || two )
    		{
    			if ( one )
    				PRINT_ERRNO( stdout, one );
    			if ( two )
    				PRINT_ERRNO( stdout, two );
    			app.err = one ? one : two;
    			break;
    		}
    
    		app.wai.file = SeekAchsArray( app.wai.File );
    		app.vai.file = SeekAchsArray( app.vai.File );
    
    		one = OpenLib( &app, &(app.wai) );
    		two = OpenLib( &app, &(app.vai) );
    
    		if ( one || two )
    		{
    			if ( one )
    			{
    				PRINT_ERROR( stdout, one );
    				printf( "Failed to open VfxWai module '%s'\n", app.wai.file );
    			}
    			if ( two )
    			{
    				PRINT_ERROR( stdout, two );
    				printf( "Failed to open VfxVai module '%s'\n", app.vai.file );
    			}
    			app.err = one ? one : two;
    			break;
    		}
    
    		app.err = MakeShadersVoids( &app );
    
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		if ( achsfind( app.vai.name, "gl" ) )
    		{
    			achs init_vfxwin_args[] =
    			{
    				"-l", app.vai.name,
    				"--major=4",
    				"--minor=3",
    				"--samples=4",
    				"--foreward-compatability=1",
    				"--profile=core",
    				NULL
    			};
    
    			app.err = InitVfxWai( &app, app.wai.hook, init_vfxwin_args );
    
    			if ( app.err )
    			{
    				PRINT_ERRNO( stdout, app.err );
    				break;
    			}
    		}
    
    		app.err = MakeVfxWin( &app, &(app.vfxwin) );
    
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = OpenVfxWin
    			( &app, app.vfxwin, "Example VfxWin", 640, 480 );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = BindVfxWin( app.vfxwin );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = InitVfxVai( &app, app.vai.hook );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = MakeVfxApp( &app, &(app.vfxapp) );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = InitVfxDbg( &app, true, debugVfx, &app );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = InitVfxApp( &app, app.vfxapp, "shaders/vfxapps.ini", NULL );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = BindVfxApp( &app, app.vfxapp );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = create( &app );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			break;
    		}
    
    		app.err = SeekVfxWinSize( app.vfxwin, &winH, &winW );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			winH = 640;
    			winW = 480;
    		}
    
    		app.err = SeekVfxWinPos( app.vfxwin, &winX, &winY );
    		if ( app.err )
    		{
    			PRINT_ERRNO( stdout, app.err );
    			winX = 0;
    			winY = 0;
    		}
    
    		app.err = MoveVfxBox( 0, 0, winH, winW );
    		if ( app.err )
    			PRINT_ERRNO( stdout, app.err );
    
    		while ( !DeadVfxWin( app.vfxwin ) )
    		{
    			ucap i;
    			SHARED_DINTS *dints =
    				SeekBufferArray( app.SharedBuffers[SHARED_BUFFER_DINTS] );
    			SHARED_FNUMS *fnums =
    				SeekBufferArray( app.SharedBuffers[SHARED_BUFFER_FNUMS] );
    			dint vertices[] = { 3, 3, 3 };
    			vec3 points[sizeof(vertices)/sizeof(dint)] =
    				{ { 0.25, 0.25, 0 }, { 0.75, 0.25, 0 }, { 0.5, 0.75, 0 } };
    			BindVfxWin( app.vfxwin );
    			BindVfxApp( &app, app.vfxapp );
    			FillVfxBox( 0.0, 0.0, 0.0, 1.0 );
    			ZeroVfxBit( VFX_COLOR_BIT | VFX_DEPTH_BIT );
    
    			if ( SeekKeyAct( app.vfxwin, VFXKEY_ANSI_ESC ) == VFXKEY_ISACTIVE )
    				KillVfxWin( &app, app.vfxwin );
    
    			app.err = SeekVfxWinSize( app.vfxwin, &winH, &winW );
    			if ( app.err )
    				PRINT_ERRNO( stdout, app.err );
    
    			app.err = SeekVfxWinPos( app.vfxwin, &winX, &winY );
    			if ( app.err )
    				PRINT_ERRNO( stdout, app.err );
    
    			dints->mem.WinSpace.x = winW;
    			dints->mem.WinSpace.y = winH;
    			dints->mem.WinPoint.x = winX;
    			dints->mem.WinPoint.y = winY;
    
    			dints->mem.VtxCount = 3;
    			memcpy( fnums->mem.RegPoint.raw, points, sizeof(points) );
    
    			for ( i = 0; i < SHARED_BUFFER_COUNT; ++i )
    				SendVfxBuf( &app, app.SharedVfxCfgs[i], app.SharedVfxBufs[i] );
    
    			DrawVfxCfg( &app, app.SharedVfxCfgs[0], VFXDRAW_TRIOS );
    
    			SwapVfxWinBufs( &app, app.vfxwin );
    			PollVfxWai();
    		}
    	}
    	while (0);
    
    	TermVfxDbg( &app, true );
    	void_shared( &app );
    	VoidShadersVoids( &app );
    	VoidVfxApp( &app, &(app.vfxapp) );
    	TermVfxVai( &app, app.vai.hook );
    	VoidVfxWin( &app, &(app.vfxwin) );
    	TermVfxWai( &app, app.wai.hook );
    	ShutLib( &app, &(app.vai) );
    	ShutLib( &app, &(app.wai) );
    	VoidStringsVoids( &app );
    	return app.err ? EXIT_FAILURE : EXIT_SUCCESS;
    }
    Attached Images Attached Images A segfault I'm unable to locate the source of-glfwterminate_callstack-png 

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unable to get debugging info to track down a segfault
    By awsdert in forum C Programming
    Replies: 5
    Last Post: 03-03-2020, 11:59 AM
  2. Replies: 4
    Last Post: 07-30-2013, 02:05 PM
  3. Replies: 1
    Last Post: 07-26-2010, 10:21 AM
  4. Unable to locate txt file for ifstream opening
    By Swerve in forum C++ Programming
    Replies: 2
    Last Post: 04-19-2008, 11:55 AM
  5. unable to locate the errors (maybe trouble with arrays)
    By Moose2Sue in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2002, 03:52 PM

Tags for this Thread