If the program is run with argc < 4, then argv[1] through argv[3] do not exist.
Consider what that means for this code in main() if the program is run with less than 3 command line arguments.
Code:
if(argc != 4) {
fprintf(stderr, "USAGE:./main.out <INT> <INT> <INT>\n");
}
int mainSleepTime = atoi(argv[1]); /* Time in seconds for main to sleep */
int numProd = atoi(argv[2]); /* Number of producer threads */
int numCons = atoi(argv[3]); /* Number of consumer threads */
The simplest fix is probably to terminate the program if argc is not equal to 4.