[Linux] Crash if screenshots dir doesn't exist or is not executable #550

Closed
opened 2022-12-03 13:00:54 -03:00 by jn64 · 3 comments
jn64 commented 2022-12-03 13:00:54 -03:00 (Migrated from github.com)

Cemu version: b361b15 (latest, built with PORTABLE=OFF)
OS: Fedora 36

Description

Cemu crashes when taking a screenshot, if:

  • Save screenshots setting is enabled, AND
  • ~/.local/share/Cemu/screenshots does not exist OR is not executable.

Cemu correctly errors but doesn't crash if:

  • the directory is not writable, OR
  • the path is not a directory (path is a file).

Steps to reproduce

Repro 1: Dir does not exist

  1. Delete ~/.local/share/Cemu/screenshots if it exists
  2. Start a game in Cemu
  3. Press F12
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: cannot create directory: No such file or directory [/home/jn/.local/share/Cemu/screenshots/Screenshot_2022-12-03_23-19-16.png]
Aborted!
Error: signal 6:
Cemu() [0x895b3f]
/lib64/libc.so.6(+0x3ea30) [0x7ff97343ea30]
/lib64/libc.so.6(+0x8ec0c) [0x7ff97348ec0c]
/lib64/libc.so.6(raise+0x16) [0x7ff97343e986]+0x16) [0x7ff97343e986]
/lib64/libc.so.6(abort+0xcf) [0x7ff9734287f4]+0xcf) [0x7ff9734287f4]
/lib64/libstdc++.so.6(+0xa2b77) [0x7ff9716a2b77]
/lib64/libstdc++.so.6(+0xae3bc) [0x7ff9716ae3bc]
/lib64/libstdc++.so.6(+0xae427) [0x7ff9716ae427]
/lib64/libstdc++.so.6(+0xae688) [0x7ff9716ae688]
/lib64/libstdc++.so.6(+0xa69d1) [0x7ff9716a69d1]
Cemu() [0x63c77e]
/lib64/libstdc++.so.6(+0xdbad3) [0x7ff9716dbad3]
/lib64/libc.so.6(+0x8cded) [0x7ff97348cded]
/lib64/libc.so.6(+0x112370) [0x7ff973512370]

Repro 2: Dir is not executable

  1. Make the screenshots dir not executable:
    $ mkdir -p ~/.local/share/Cemu/screenshots
    $ chmod -x ~/.local/share/Cemu/screenshots
    
  2. Start a game in Cemu
  3. Press F12

Note the different error on line 2:

terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: status: Permission denied [/home/jn/.local/share/Cemu/screenshots/Screenshot_2022-12-03_23-30-19.png]
Aborted!
Error: signal 6:
Cemu() [0x895b3f]
/lib64/libc.so.6(+0x3ea30) [0x7f6546a3ea30]
/lib64/libc.so.6(+0x8ec0c) [0x7f6546a8ec0c]
/lib64/libc.so.6(raise+0x16) [0x7f6546a3e986]+0x16) [0x7f6546a3e986]
/lib64/libc.so.6(abort+0xcf) [0x7f6546a287f4]+0xcf) [0x7f6546a287f4]
/lib64/libstdc++.so.6(+0xa2b77) [0x7f6544ea2b77]
/lib64/libstdc++.so.6(+0xae3bc) [0x7f6544eae3bc]
/lib64/libstdc++.so.6(+0xae427) [0x7f6544eae427]
/lib64/libstdc++.so.6(+0xae688) [0x7f6544eae688]
/lib64/libstdc++.so.6(+0xa72c9) [0x7f6544ea72c9]
Cemu() [0x63c639]
/lib64/libstdc++.so.6(+0xdbad3) [0x7f6544edbad3]
/lib64/libc.so.6(+0x8cded) [0x7f6546a8cded]
/lib64/libc.so.6(+0x112370) [0x7f6546b12370]
Cemu version: b361b15 (latest, built with `PORTABLE=OFF`) OS: Fedora 36 ## Description Cemu crashes when taking a screenshot, if: - *Save screenshots* setting is enabled, AND - `~/.local/share/Cemu/screenshots` does not exist OR is not executable. Cemu correctly errors but *doesn't* crash if: - the directory is not writable, OR - the path is not a directory (path is a file). ## Steps to reproduce ### Repro 1: Dir does not exist 1. Delete `~/.local/share/Cemu/screenshots` if it exists 2. Start a game in Cemu 3. Press F12 ```sh terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error' what(): filesystem error: cannot create directory: No such file or directory [/home/jn/.local/share/Cemu/screenshots/Screenshot_2022-12-03_23-19-16.png] Aborted! Error: signal 6: Cemu() [0x895b3f] /lib64/libc.so.6(+0x3ea30) [0x7ff97343ea30] /lib64/libc.so.6(+0x8ec0c) [0x7ff97348ec0c] /lib64/libc.so.6(raise+0x16) [0x7ff97343e986]+0x16) [0x7ff97343e986] /lib64/libc.so.6(abort+0xcf) [0x7ff9734287f4]+0xcf) [0x7ff9734287f4] /lib64/libstdc++.so.6(+0xa2b77) [0x7ff9716a2b77] /lib64/libstdc++.so.6(+0xae3bc) [0x7ff9716ae3bc] /lib64/libstdc++.so.6(+0xae427) [0x7ff9716ae427] /lib64/libstdc++.so.6(+0xae688) [0x7ff9716ae688] /lib64/libstdc++.so.6(+0xa69d1) [0x7ff9716a69d1] Cemu() [0x63c77e] /lib64/libstdc++.so.6(+0xdbad3) [0x7ff9716dbad3] /lib64/libc.so.6(+0x8cded) [0x7ff97348cded] /lib64/libc.so.6(+0x112370) [0x7ff973512370] ``` ### Repro 2: Dir is not executable 1. Make the screenshots dir not executable: ```sh $ mkdir -p ~/.local/share/Cemu/screenshots $ chmod -x ~/.local/share/Cemu/screenshots ``` 2. Start a game in Cemu 3. Press F12 Note the different error on line 2: ```sh terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error' what(): filesystem error: status: Permission denied [/home/jn/.local/share/Cemu/screenshots/Screenshot_2022-12-03_23-30-19.png] Aborted! Error: signal 6: Cemu() [0x895b3f] /lib64/libc.so.6(+0x3ea30) [0x7f6546a3ea30] /lib64/libc.so.6(+0x8ec0c) [0x7f6546a8ec0c] /lib64/libc.so.6(raise+0x16) [0x7f6546a3e986]+0x16) [0x7f6546a3e986] /lib64/libc.so.6(abort+0xcf) [0x7f6546a287f4]+0xcf) [0x7f6546a287f4] /lib64/libstdc++.so.6(+0xa2b77) [0x7f6544ea2b77] /lib64/libstdc++.so.6(+0xae3bc) [0x7f6544eae3bc] /lib64/libstdc++.so.6(+0xae427) [0x7f6544eae427] /lib64/libstdc++.so.6(+0xae688) [0x7f6544eae688] /lib64/libstdc++.so.6(+0xa72c9) [0x7f6544ea72c9] Cemu() [0x63c639] /lib64/libstdc++.so.6(+0xdbad3) [0x7f6544edbad3] /lib64/libc.so.6(+0x8cded) [0x7f6546a8cded] /lib64/libc.so.6(+0x112370) [0x7f6546b12370] ```
ghost commented 2022-12-03 13:07:03 -03:00 (Migrated from github.com)

This should probably be fs::create_directories(screendir.parent_path()) b361b154d8/src/Cafe/HW/Latte/Renderer/Renderer.cpp (L148)

This should probably be `fs::create_directories(screendir.parent_path())` https://github.com/cemu-project/Cemu/blob/b361b154d8ac6e8f7c34a1c9c3c7e97e66fb0d0b/src/Cafe/HW/Latte/Renderer/Renderer.cpp#L148
ghost commented 2022-12-03 13:58:04 -03:00 (Migrated from github.com)

b361b154d8/src/Cafe/HW/Latte/Renderer/Renderer.cpp (L105)
This is where the crash is when the dir. is not executable. There's a blank std::error_code above this so perhaps the noexcept version of fs::exists was meant to be used.

https://github.com/cemu-project/Cemu/blob/b361b154d8ac6e8f7c34a1c9c3c7e97e66fb0d0b/src/Cafe/HW/Latte/Renderer/Renderer.cpp#L105 This is where the crash is when the dir. is not executable. There's a blank `std::error_code` above this so perhaps the `noexcept` version of fs::exists was meant to be used.
jn64 commented 2022-12-06 22:45:47 -03:00 (Migrated from github.com)

Thanks! Confirmed fixed in every situation.

Thanks! Confirmed fixed in every situation.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cemu-project_Mirror/Cemu-2024-03-05#550
No description provided.