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

Wrong relative path in saved shader preset #9724

Closed
cmitu opened this issue Nov 15, 2019 · 0 comments
Closed

Wrong relative path in saved shader preset #9724

cmitu opened this issue Nov 15, 2019 · 0 comments

Comments

@cmitu
Copy link
Contributor

cmitu commented Nov 15, 2019

Description

There is a bug in the path_relative_to function that makes saving shader presets store the wrong path in the preset file.
The issue happens when the shader preset loaded in RetroArch has

  • the filename starting with p
  • location in $HOME/.config/retroarch/shaders

When trying to save the shader preset (per-game or per-core, but I don't think it matters), RetroArch tries to save a relative path to the loaded preset and invokes path_relative_to to get a relative path to the loaded shader.

path_relative_to(preset_ref, clean_shader_path, clean_path, PATH_MAX_LENGTH);
.

However, path_relative_to will produce a wrong result because it strips the p from both presets and the shader preset name, resulting in a wrong relative path.

for (i = 0; path[i] && base[i] && path[i] == base[i]; )
i++;
trimmed_path = path+i;
trimmed_base = base+i;
/* Each segment of base turns into ".." */
out[0] = '\0';
for (i = 0; trimmed_base[i]; i++)
if (trimmed_base[i] == path_default_slash_c())
strlcat(out, ".." path_default_slash(), size);

Expected behavior

Shader preset should contain the correct relative path.

Actual behavior

Shader preset saves the wrong relative path to the actual shader.

Steps to reproduce the bug

  1. Copy phosphorglut.glslp (and the necessary pre-requisites) to $HOME/.config/retroarch/shaders.

  2. Start RetroArch and load the shader.

  3. Try to save the a Game or Core preset. The game/core preset file is created, but RetroArch fails to re-load the shader and disables the shader.

The preset file created by save has the wrong path and contains

 #reference ../../hosphorgut.glslp

instead of containing

 #reference ../phosphorgut.glslp

Bisect Results

Not sure if it path_relative_to was working properly before, but the shader preset was overhauled in #9315.

Version/Commit

You can find this information under Information/System Information

  • RetroArch: 1.8.1 (latest master)

Environment information

  • OS: Linux, Raspbian Buster.
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

No branches or pull requests

1 participant