Bug 202277 - [GTK][WPE] Stray files left under /tmp if UIProcess exits while a content extension is being compiled
Summary: [GTK][WPE] Stray files left under /tmp if UIProcess exits while a content ext...
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-26 10:30 PDT by Adrian Perez
Modified: 2019-09-26 10:40 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Perez 2019-09-26 10:30:05 PDT
See https://gitlab.gnome.org/GNOME/epiphany/merge_requests/438

Ideally we would have WebKit clean up after itself. The best option
would be to not need using named temporary files during compilation;
that way the kernel would clean up automatically when the file
descriptor is closed during the process exit.
Comment 1 Adrian Perez 2019-09-26 10:40:27 PDT
In Linux we can use “open("/path/to/dir", mode | O_TMPFILE)” to get
a file descriptor which is not linked to a directory entry in the
file system. If the process exits or drops the file handle cleanup
is automatic. Such a file descriptor can be directly linked into
its final location using “linkat()” passing “/proc/self/fd/<num>”
as the first path.

While the above is very neat, we still need some other mechanism
for other systems (the BSDs come to mind). In that case, I think
a reasonable fallback is to unlink the temporary file immediately
after its creation, then once compilation ended create a *new* file
into the final location, truncate it to the right size, and copy
the data. Note that in the current implementation a data copy is
already being performed if “/tmp” and the storage location for
a WebKitUserContentFilterStore aren't inside the same mount point
(not uncommon with “/tmp” very often being an on-RAM file system
and “/home” often being a separate volume).

If somebody is aware of something similar to Linux's “O_TMPFILE”
which would work on other common systems we support, I would love
to hear about it =)