GPU_LoadShader crashes when I pass a parameter, but not a string literal.

I know this is not a supported library, but I wasn’t sure where else to ask.

Anyway, here’s my relevant code:

GPU_ShaderEnum GetShaderEnum(int i)
{
	switch(i)
	{
		case 0:
			return GPU_VERTEX_SHADER;
		case 1:
			return GPU_FRAGMENT_SHADER;
		case 2:
			return GPU_GEOMETRY_SHADER;
	}
}

Uint32 My_GPU_LoadShader(int shader_type, char* filename)
{
	FILE* fp = fopen("output.txt", "w");
	fprintf(fp, "filename: %s\r\n", filename);
	//It seems this will crash when I pass the parameter; it only succeeds when I give it a literal.
	//Uint32 output = GPU_LoadShader(GetShaderEnum(shader_type), "mypath\myshader.vert");
	Uint32 output = GPU_LoadShader(GetShaderEnum(shader_type), filename);
	fprintf(fp, "Done loading!");
	return output;
}

As I’ve commented, if I pass it the string literal, there’s no problem (or at least, it doesn’t crash the whole thing). But when I simply pass in filename, the whole exe crashes before it can fprintf “Done loading!” Even if I copy/paste the contents of that output file in order to get the string literal.

I checked to make sure my parameter was null terminated (it was), because it was the only thing I could think of.

The error reporting is kinda weird, since I’m calling this (C) function from Ada code, but it seems it might be relevant?

raised STORAGE_ERROR : stack overflow or erroneous memory access

Which is more or less the same thing as a segfault. So maybe that’s what it is behind the scenes?

It’s probably a really obvious newbie C thing. Any ideas?

GPU_LoadShader(GetShaderEnum(shader_type), "mypath\myshader.vert")

What happens if you instead pass the string literal "mypath\\myshader.vert" or "mypath/myshader.vert" ?

Bah, of course. It’s been too long since I’ve done C.

SDL_GPU probably handles nonexistent files using its own error handling, before it does whatever is making this crash.

Anyway, when I escape the backslash, it crashes either way.

I dunno if it matters, but here’s the code for the shader:

#version 330

layout(location = 0) in vec4 in_position;

void main()
{
    gl_Position = in_position;
}

It’s supposed to be just a generic passthrough vertex shader, which I’m going to try to link with a fragmentation shader. It compiles fine against glslValidator.