Skip to content

memfd_create() is not available #3542

Closed

Description

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

Activity

  1. therealkenc commented on Sep 19, 2018

    @therealkenc

    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.

  2. therealkenc commented on Oct 17, 2018

    @therealkenc

    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.

  3. Brian-Perkins commented on Oct 17, 2018

    @Brian-Perkins
    Contributor

    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.

  4. therealkenc commented on Oct 17, 2018

    @therealkenc

    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.

  5. incube8r commented on May 29, 2019

    @incube8r

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

  6. linkmauve commented on Oct 17, 2019

    @linkmauve

    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

  7. yecril71pl commented on Dec 2, 2019

    @yecril71pl

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions