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

core.fs: Not changing into drive directory, sometimes #12

Open
obiwac opened this issue Nov 11, 2022 · 0 comments
Open

core.fs: Not changing into drive directory, sometimes #12

obiwac opened this issue Nov 11, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@obiwac
Copy link
Member

obiwac commented Nov 11, 2022

It seems opening a file may sometimes fail because the current process is not in the right drive directory. This is likely due to a race condition. Relevant code from core.fs:

if (chdir(dir) < 0) {
	LOG_WARN("Couldn't change into drive directory of '%s:%s' ('%s')", drive, path, dir)
	goto chdir_error;
}

... // between when we changed into dir and when realpath is called, we may have changed directories on another thread

char* abs_path = realpath(path, NULL); // abs_path is NULL, realpath fails with "No such file or directory"

Example log:

[VERBOSE core.fs -> ./core.fs/functions.h:130 -> fs_open] realpath("cfg:cursors/drag.svg") (from within "/home/obiwac/.aqua//conf"): No such file or directory
[WARN core.fs -> ./core.fs/functions.h:224 -> fs_mmap] Descriptor pointer is NULL
[INFO aquabsd.alps.svg -> ./aquabsd.alps.svg/functions.h:23 -> load_svg] Load SVG (0x0)
[VERBOSE aquabsd.alps.svg -> ./aquabsd.alps.svg/functions.h:42 -> load_svg] SVG hash is aa8f1bc7fdb8e660

This kind of problem wouldn't happen if POSIX had a proper way of checking path hierarchy ;)

@obiwac obiwac added the bug Something isn't working label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant