Unable To FS_createPreloadedFile A File With Emsdk 1.37.16 And ALLOW_MEMORY_GROWTH

49 views
Skip to first unread message

awt

unread,
Oct 11, 2017, 2:31:26 AM10/11/17
to emscripten-discuss
Hi,

I tried to load an 8mb data file with FS_createPreloadedFile and Emsdk 1.37.16 And ALLOW_MEMORY_GROWTH. What I observed is that in the mmap function, we try to set to a buffer that is zero bytes in size. However, if I use TOTAL_MEMORY_GROWTH, the size of buffer will be that of what I pass to TOTAL_MEMORY_GROWTH. Is this a known issue?

mmap: (function(stream, buffer, offset, length, position, prot, flags) {
   if (!FS.isFile(stream.node.mode)) {
    throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
   }
   var ptr;
   var allocated;
   var contents = stream.node.contents;
   if (!(flags & 2) && (contents.buffer === buffer || contents.buffer === buffer.buffer)) {
    allocated = false;
    ptr = contents.byteOffset;
   } else {
    if (position > 0 || position + length < stream.node.usedBytes) {
     if (contents.subarray) {
      contents = contents.subarray(position, position + length);
     } else {
      contents = Array.prototype.slice.call(contents, position, position + length);
     }
    }
    allocated = true;
    ptr = _malloc(length);
    if (!ptr) {
     throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
    }
    buffer.set(contents, ptr);
   }
   return {
    ptr: ptr,
    allocated: allocated
   };
  }),

Jukka Jylänki

unread,
Oct 11, 2017, 1:31:30 PM10/11/17
to emscripte...@googlegroups.com
This does not sound like anything we have encountered before. Would
you have a small test case to highlight this?
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-disc...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages