Thread: Need a little help spotting potential causes of a problem

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,048

    Need a little help spotting potential causes of a problem

    First a link to the tree before I forget:
    GitHub - awsdert/gasp at 3b829258bbaa716314b15b023ed0367e5fcf6ed1

    These are the scenarios that I'm programming around (using > to represent launch action, # to represent environment variables passed on):
    Code:
    user > gasp
    user > gasp > pkexec > gasp -D HAVE_ROOT_PERM #
    user > gasp -D USE_GEDE  > pkexec > gasp -D HAVE_ROOT_PERM -D USE_GEDE # > gede --args gasp -D HAVE_ROOT_PERM #
    The last scenario currently fails with this output (paths where edited):
    Code:
    ./gasp-d.elf -D USE_GEDE
    .../gasp-d.elf -D USE_GEDE -D HAS_ROOT_PERM  -D PWD=".../gasp" -D HOME="~" -D DISPLAY=":0" -D XDG_CURRENT_DESKTOP="X-Cinnamon" -D GDMSESSION="cinnamon"
    gasp.c:434:main() 0x0000008B
    External Msg 'Unknown error 139'
    Internal Msg 'Test failed'
    make: *** [makefile:134: test] Error 1
    Compilation failed.
    The only function I currently find suspect is this one:
    Code:
    int launch_test_gasp(
    	nodes_t *ARGS, space_t *CMDL, char const *defines
    )
    {
    	int ret = 0;
    	char const *launch, *gede = "USE_GEDE",
    		*PWD = getenv("PWD"), *CWD = getenv("CWD");
    	char *cmdl, *key, *val;
    	node_t i;
    	size_t need;
    	kvpair_t *kvpair, *kvpairs;
    	
    	if ( !g_launch_dbg )
    		return EINVAL;
    	launch = "gasp-d.elf";
    	
    	if ( !PWD ) PWD = CWD;
    	
    	need = BUFSIZ;
    	need += strlen(launch) + 1; /* For '\0' */
    	need += strlen(PWD) + 1; /* For '\0' */
    	need += strlen(gede) + 5; /* For " -D " '\0' */
    	
    	kvpairs = ARGS->space.block;
    	for ( i = 0; i < ARGS->count; ++i )
    	{
    		kvpair = kvpairs + i;
    		key = kvpair->key.block;
    		val = kvpair->val.block;
    		need += strlen( key ) + strlen( val ) + 3;
    	}
    	
    	if ( (ret = more_space( CMDL, need )) != 0 )
    		return ret;
    	
    	cmdl = CMDL->block;
    	sprintf( cmdl, "gede --args %s/%s %s", PWD, launch, defines );
    
    	for ( i = 0; i < ARGS->count; ++i )
    	{
    		kvpair = kvpairs + i;
    		key = kvpair->key.block;
    		val = kvpair->val.block;
    		if ( key[0] == '-' && key[1] == 'D' && strstr( cmdl, val ) )
    			continue;
    		
    		if ( val && *val )
    			sprintf( strchr( cmdl, '\0'), " %s %s", key, val );
    		else
    			sprintf( strchr( cmdl, '\0'), " %s", key );
    	}
    	
    	/* Prevent infinite loop */
    	key = strstr( cmdl, " -D USE_GEDE" );
    	for ( i = 0; i < 12; ++i ) key[i] = ' ';
    	
    	fprintf( stderr, "%s\n", cmdl );
    	return system( cmdl );
    }
    I need to go to shops before they close so I'll try any suggestions when I get back

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,048
    I think it may have been a memory issue, I fiddled about with some stuff so that text allocations would be all initialised via a loop in main(), finally got through after that, also changed the -D USE_GEDE to --gede so that it would not be set as an environment variable, just updating the arguments() function to support more than just -D options (to an extent)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need a some help spotting the cause of an issue
    By awsdert in forum C Programming
    Replies: 4
    Last Post: 03-15-2020, 07:53 AM
  2. Beginner having difficulty spotting problem
    By Neverender! in forum C Programming
    Replies: 6
    Last Post: 03-23-2016, 09:53 AM
  3. Bulls and Cows Program - Spotting the Problem
    By YannB in forum C Programming
    Replies: 8
    Last Post: 12-19-2013, 10:37 AM
  4. Spotting the error...
    By Enegis in forum C++ Programming
    Replies: 3
    Last Post: 11-17-2008, 05:51 AM
  5. winHTTP : spotting a 404 (and other server errors)
    By reanimated in forum Windows Programming
    Replies: 1
    Last Post: 05-28-2004, 05:58 PM

Tags for this Thread