snake game doesnt work

im starting to make an snake game based on old “tron-like” code and im currently trying to make a select amount of generated “body parts” move behind each other behind the player head, when i am able to do this, i know how to do the rest of the game, but in trying to make this work, for about the past month or 2(probably like 2) its not been working, in this case, when i try to make the initial move, the game resets and the console says “passed a NULL mutex”, and this only started occuring when i put a condition in the main loop to say only move the body parts if the vector of rects containing them has at least 1 position stored, where is my issue in the following code:

#include "SDL_Test.h"

 int main(int args, char* argc[])
{
std::cout << "this code can be updated into a snake game!\n";
 egin:
std::cout << SDL_GetError() << "\n";
// before SDL init
const int WinW{ 700 }; const int WinH{ 700 };

// SDL init
Init();
SDL_Window* win{ SDL_CreateWindow("SDL TRON-STYLE 2D COLLISION DEMO", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WinW, WinH, SDL_WINDOW_SHOWN) };
SDL_Renderer* ren{ SDL_CreateRenderer(win, -1, SDL_RENDERER_INIT) };

const int GridPointSize{ 5 };

// player variables
SDL_Rect Player{ random(WinW / GridPointSize) * GridPointSize, random(WinH / GridPointSize) * GridPointSize, GridPointSize, GridPointSize };
std::vector<SDL_Rect> PlayerPlacements{}; uint32_t pSteps = 0; int dir{};

// other variables
SDL_Event e; bool q{ false }; bool restart{ false }, moving{ false };

// main loop
while (!q)
{
	SDL_SetRenderDrawColor(ren, 0, 0, 0, 255);
	SDL_RenderClear(ren);

	RenderDrawGrid(ren, WinW, WinH, GridPointSize);

	SDL_SetRenderDrawColor(ren, 20, 0, 255, 255);
	SDL_RenderFillRect(ren, &Player);
	SDL_RenderFillRects(ren, PlayerPlacements.data(), PlayerPlacements.size());

	SDL_RenderPresent(ren);
	while (SDL_PollEvent(&e))
	{
		if (e.type == SDL_QUIT) q = true;
		else if (e.type == SDL_KEYDOWN)
		{
			switch (e.key.keysym.sym)
			{
			case SDLK_w: if (dir != 2) dir = 1; break; // move up if not moving down
			case SDLK_s: if (dir != 1) dir = 2; break; // move down if not moving up
			case SDLK_a: if (dir != 4) dir = 3; break; // move left if not moving right
			case SDLK_d: if (dir != 3) dir = 4; break; // move right if not moving left
			case SDLK_p: restart = true; q = true; break; // force restart
			case SDLKES: q = true; break; // quit
			}
		}
	}
	switch (dir)
	{
	case 1:
		if (Player.y > 0)
		{
			if (PlayerPlacements.size() < 5) PlayerPlacements.push_back(Player);
			Player.y -= GridPointSize;
			if (PlayerPlacements.size() > 0) for (unsigned int i = 1; i < PlayerPlacements.size(); 
 i++) PlayerPlacements.at(i).y -= GridPointSize;
		}
		break;
	case 2:
		if (Player.y < (WinH - GridPointSize))
		{
			if (PlayerPlacements.size() < 5) PlayerPlacements.push_back(Player);
			Player.y += GridPointSize;
			if (PlayerPlacements.size() > 0) for (unsigned int i = 1; i < PlayerPlacements.size(); 
i++) PlayerPlacements.at(i).y += GridPointSize;
		}
		break;
	case 3:
		if (Player.x > 0)
		{
			if (PlayerPlacements.size() < 5) PlayerPlacements.push_back(Player);
			Player.x -= GridPointSize;
			if (PlayerPlacements.size() > 0) for (unsigned int i = 1; i < PlayerPlacements.size(); 
  i++) PlayerPlacements.at(i).x -= GridPointSize;
		}
		break;
	case 4:
		if (Player.x < (WinW - GridPointSize))
		{
			if (PlayerPlacements.size() < 5) PlayerPlacements.push_back(Player);
			Player.x += GridPointSize;
			if (PlayerPlacements.size() > 0) for (unsigned int i = 1; i < PlayerPlacements.size(); 
 i++) PlayerPlacements.at(i).x += GridPointSize;
		}
		break;
	}
	for (unsigned int pp = 0; pp < PlayerPlacements.size(); pp++) { if 
(SDL_HasIntersection(&Player, &PlayerPlacements[pp])) { restart = true; q = true; } }
	SDL_Delay(50);
}

// exit code
WinList wins{ win };
RenList rens{ ren };
QuitSDL(wins, rens);
if (restart) goto begin;
return 0;
}

i should also note quickly that my custom code mostly contains typedefs to vectors(WinList and RenList), and then Init() and QuitSDL() should be obvious, the rest is purely C++/SDL, what changes should i make to make the pieces follow the player, this is getting annoying