RESOLVED FIXED 254813
REGRESSION(259689@main): [GLib] openFile() fails to create files
https://bugs.webkit.org/show_bug.cgi?id=254813
Summary REGRESSION(259689@main): [GLib] openFile() fails to create files
Alicia Boya García
Reported 2023-03-31 07:52:06 PDT
How to reproduce: $ run-webkit-httpd $ TEST_RUNNER_TEST_PLUGIN_PATH=this_env_var_is_no_longer_used_and_shouldnt_be_required_but_that_is_work_for_another_patch \ webkit-flatpak --gtk --debug -c \ /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner --show-window http://localhost:8000/media-resources/media-source/media-source-seek-unbuffered.html [...] ERROR: writeOriginToFile: Failed to open origin file '/home/ntrrgc/.local/share/WebKitTestRunner/storage/4NoLZrGDXutAmUUf2IXlV4GkA_dI4PpgaXiB2xqjhow/4NoLZrGDXutAmUUf2IXlV4GkA_dI4PpgaXiB2xqjhow/origin' /app/webkit/Source/WebKit/NetworkProcess/storage/StorageUtilities.h(73) : bool WebKit::writeOriginToFile(const WTF::String &, const WebCore::ClientOrigin &) There is nothing wrong about the path above. This is the call that is being made: auto originFileHandle = FileSystem::openFile(filePath, FileSystem::FileOpenMode::ReadWrite[, failIfFileExists = false]); The problem is openFile() is using g_file_open_readwrite() in this code path, which fails if the file doesn't exist. The following is a table of valid GIO functions for creating an stream with permissions requested by WebKit: +-----------+-------------------------+----------------------------+ | Mode | failIfFileExists | Call | +-----------+-------------------------+----------------------------+ | Read | (any, will always fail) | g_file_read() | | Truncate | true | g_file_create() | | Truncate | false | g_file_replace() | | ReadWrite | true | g_file_create_readwrite() | | ReadWrite | false | g_file_replace_readwrite() | +-----------+-------------------------+----------------------------+
Attachments
Alicia Boya García
Comment 1 2023-04-06 07:04:47 PDT
I'm working on a fix.
Alicia Boya García
Comment 2 2023-04-07 09:32:14 PDT
This turned out to be a bigger rabbit hole than I expected. I'm not very happy with GIO's API. The previous table I made is incorrect, as g_file_replace_readwrite() followed by a close() effectively truncates the file.
Alicia Boya García
Comment 3 2023-04-07 09:46:01 PDT
EWS
Comment 4 2023-04-25 06:49:30 PDT
Committed 263367@main (78d2561b2bf7): <https://commits.webkit.org/263367@main> Reviewed commits have been landed. Closing PR #12511 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.