FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

munmap fails if file has been closed · Issue #20459 · emscripten-core/emscripten · GitHub

munmap fails if file has been closed #20459

Description

In linux, you can do:

  1. open file
  2. memory map a region of the file (mmap)
  3. close file
  4. do stuff with the memory mapped region
  5. munmap region

In emscripten, it mostly works, but munmap returns -1 if the file is closed.

test.c

#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main()
{
    int fd;
    char *addr;
    int result;

    fd=open("test-unmap.c",O_RDONLY);
    addr=mmap(NULL,64,PROT_READ,MAP_SHARED,fd,0);
    close(fd);
    // this call should succeed, but actually fails
    result=munmap(addr,64);
    printf("%d\n",result);
}

To reproduce:
emcc test-unmap.c -lnodefs.js -lnoderawfs.js

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL