Bug 237477

Summary: Add null check for path in makeAllDirectories
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: New BugsAssignee: Sihui Liu <sihui_liu>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, darin, ews-watchlist, ggaren, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Sihui Liu 2022-03-04 11:23:11 PST
...
Comment 1 Sihui Liu 2022-03-04 11:30:39 PST
Created attachment 453859 [details]
Patch
Comment 2 Chris Dumez 2022-03-04 14:30:06 PST
Comment on attachment 453859 [details]
Patch

Your test is failing on api-gtk.
Comment 3 Darin Adler 2022-03-04 15:10:10 PST
Comment on attachment 453859 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453859&action=review

> Source/WTF/wtf/posix/FileSystemPOSIX.cpp:280
> +        LOG_ERROR("File failed to access. Error message: %s", safeStrerror(errno).data());

I think "file failed to access" is a vague message to put in a log, and not how I would describe a failure of the access function. If we are going to log this, then the message should make some mention of the fact that were were attempting to create directories, perhaps. Also wondering why we decided to log about the failure of this access call but not about the failures of the other access and mkdir calls below.

Generally we want these file system abstraction functions like makeAllDirectories to not log directly to the console, so callers can make calls they know will or might fail without unconditionally cluttering logs. I understand that this conflicts with the desire to know what’s happening when diagnosing a bug. I’m not sure there is an easy answer. Generally speaking it would not be good if all file system calls logged what happened directly to the console, and certainly that’s not how the underlying POSIX functions behave.
Comment 4 Sihui Liu 2022-03-04 16:32:18 PST
Comment on attachment 453859 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453859&action=review

>> Source/WTF/wtf/posix/FileSystemPOSIX.cpp:280
>> +        LOG_ERROR("File failed to access. Error message: %s", safeStrerror(errno).data());
> 
> I think "file failed to access" is a vague message to put in a log, and not how I would describe a failure of the access function. If we are going to log this, then the message should make some mention of the fact that were were attempting to create directories, perhaps. Also wondering why we decided to log about the failure of this access call but not about the failures of the other access and mkdir calls below.
> 
> Generally we want these file system abstraction functions like makeAllDirectories to not log directly to the console, so callers can make calls they know will or might fail without unconditionally cluttering logs. I understand that this conflicts with the desire to know what’s happening when diagnosing a bug. I’m not sure there is an easy answer. Generally speaking it would not be good if all file system calls logged what happened directly to the console, and certainly that’s not how the underlying POSIX functions behave.

I added the log here because I realized that !access() does not necessarily mean file does not exist; it could be something more serious (like the fullPath is null case).
(I planned to add early return on errno != ENOENT, instead of error log, but I am not sure if that would exclude some valid cases...)

I think it's fair that we don't want to indroduce unnecessary logs for file system calls. Since there's no known issue here so far, I will remove this line.
Comment 5 Sihui Liu 2022-03-04 16:46:42 PST
Created attachment 453881 [details]
Patch
Comment 6 EWS 2022-03-04 22:03:23 PST
Committed r290862 (248093@main): <https://commits.webkit.org/248093@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453881 [details].
Comment 7 Radar WebKit Bug Importer 2022-03-04 22:04:18 PST
<rdar://problem/89848974>