Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when using r_glsl_dumpshader #145

Closed
hemebond opened this issue Mar 17, 2024 · 1 comment · Fixed by #147
Closed

Segmentation fault when using r_glsl_dumpshader #145

hemebond opened this issue Mar 17, 2024 · 1 comment · Fixed by #147

Comments

@hemebond
Copy link
Contributor

1 possible command:
r_glsl_dumpshader: dumps the engine internal default.glsl shader into glsl/default.glsl
]r_glsl_dumpshader 


    Engine Crash: Segmentation fault    
./darkplaces-sdl(+0x15ccfe)[0x563a21faacfe]
./darkplaces-sdl(Cmd_CL_Callback+0x43)[0x563a21f6a3f3]
./darkplaces-sdl(Cmd_ExecuteString+0x110)[0x563a21f6c5b0]
./darkplaces-sdl(Cmd_PreprocessAndExecuteString+0x175)[0x563a21f6ca45]
./darkplaces-sdl(Cbuf_Execute+0x60)[0x563a21f6cab0]
./darkplaces-sdl(Cbuf_Frame+0x161)[0x563a21f6cd61]
./darkplaces-sdl(Host_Main+0x1b0)[0x563a21fdc570]
./darkplaces-sdl(main+0x1ce)[0x563a21ec5ede]
/lib/x86_64-linux-gnu/libc.so.6(+0x276ca)[0x7f3c8a2fa6ca]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7f3c8a2fa785]
./darkplaces-sdl(_start+0x21)[0x563a21ec5fd1]
DarkPlaces-Quake Linux, buildstring: v20140513-1441-g02cc3403 Mar 17 2024 release
Segmentation fault
@Baker7
Copy link

Baker7 commented Mar 18, 2024

When it worked ...

int i, language, mode, dupe;

At some point it became ...

unsigned i, language, mode, dupe;

And now it does not work.

In part because


			if (dupe >= 0)
				continue;

Since dupe can never be below zero as unsigned. There is also assignment to dupe = mode - 1, which probably results in a number in the billions as the index if the mode is 0, so that would be where the out-of-bounds causes a segfault I would guess.

Side note: Did you know Java does not have unsigned? The explanation of design reason was brilliant. unsigned is a very dangerous type that is hostile to subtraction. I personally try to avoid using unsigned or size_t when easily possible and if I have to use them (instead of ssize_t --- the signed version of size_t) I always triple check no subtraction or comparisons are happening where it can go wrong.

bones-was-here pushed a commit to hemebond/darkplaces that referenced this issue Apr 1, 2024
In 05bc755 only i should have been
changed to unsigned to prevent the warning.

Fixes DarkPlacesEngine#145

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants