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

memfd_create() is not available #3542

Closed
josephapg opened this issue Sep 14, 2018 · 7 comments
Closed

memfd_create() is not available #3542

josephapg opened this issue Sep 14, 2018 · 7 comments

Comments

@josephapg
Copy link

Windows build number: 10.0.17134.285
Distro: Ubuntu 18.04.1 LTS

I want to use NGINX Unit but it fails with the following error:

{
    "error": "Memory allocation failed."
}

Here's the content of /var/log/unit.log:

[info] 7148#7148 discovery started
[notice] 7148#7148 module: python 3.6.5 "/usr/lib/unit/modules/python3.6.unit.so"
[info] 7150#7150 controller started
[notice] 7146#7146 process 7148 exited with code 0
[info] 7151#7151 router started
[alert] 7150#7150 *3 memfd_create(/unit.7150.7fd46a63) failed (38: Function not implemented)
[alert] 7150#7150 *4 memfd_create(/unit.7150.aca6c7) failed (38: Function not implemented)

This happened when I tried to configure it using
curl -X PUT -d @/path/to/configuration.json --unix-socket /run/control.unit.sock http://localhost/config/applications/app_name

@therealkenc
Copy link
Collaborator

Ref #1209 for sport. I had forgotten it was left open as a landing zone for memfd and then closed it because the use case was satisfied.

@therealkenc
Copy link
Collaborator

therealkenc commented Oct 17, 2018

Query for the devs: How "doable" is memfd_create() given the plumbing WSL has on hand? Normal "if it were easy it would exist" rules apply, natch. But I'm curious if it is in the realm of reasonably possible, or a bridge too far for the foreseeable future. Put another way, is lack thereof due mostly because it is fundamentally going to be hard (colloquially, "impossible") to map the behavior onto what you got, or because there is not a lot of demand (fairly demonstrably, given the large swaths of Linux-land that don't need it). I have some time-sink code that could use memfd, but upon thinking about it for a minute and hypothesizing on WSL internals I'm starting to wonder if this is a "straightforward to ask but hard to do" kind of thing.

@Brian-Perkins
Copy link

We have thus far avoided implementing memory-backed files (memfd, tmpfs, et al.), instead relying on the system drive for temporary storage (aka really slow memory). We could do something similar here, in which case it would just be a little bit of infrastructure to handle the lifetimes of "anonymous" files. A better solution would require plumbing in some real tmpfs concepts, and that will be quite a bit more work, though I am not aware of any technical blockers.

@therealkenc
Copy link
Collaborator

Appreciate the reply Brian. My headspace when I wrote the query was in what you called "real tmpfs concepts" (which I know WSL doesn't have), but of course you can do anything memfd_create() can do with a real temp file (which is otherwise ignored) and a mmap(). Mild duh to self, thanks. Points to (rather obvious) approach for the time-sink code too. I just wasn't thinking about it straight, because my head was stuck in anonymous memory.

@incube8r
Copy link

Adding reference to NGINX Unit issue:
nginx/unit#256

@linkmauve
Copy link

linkmauve commented Oct 17, 2019

memfd_create()’s main benefit is to be able to place seals on the fd, so that other processes receiving this fd can know for sure it won’t e.g. shrink under their feet, this isn’t possible on Linux with other filesystems so far, including tmpfs.

See the File Sealing section in the fcntl(2) manpage: https://manpages.ubuntu.com/manpages/xenial/man2/fcntl.2.html

@yecril71pl
Copy link

yecril71pl commented Dec 2, 2019

Firefox crashes on openSUSE 15.1 (in mozilla::layers::MemoryTextureHost::DeallocateSharedData).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants