emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Incoming mmap alignment changes breaks reading from mmap'd file

Open ssj-gz opened this issue 13 years ago • 2 comments

Me again ;)

9f8132c93fc0669e08187f55204f440f8363b9a1 causes breakage when trying to read from a mmap'd file, as we return an adjusted pointer that no longer points to the beginning of the actual file data.

I'm afraid I don't have a convenient test case as it is currently locked deep in the bowels of Qt ;)

Doing something like this:

if (ptr % PAGE_SIZE != 0) { var old = ptr; ptr = _malloc(num + PAGE_SIZE); ret = alignMemoryPage(ptr); _memcpy(ret, old, num); _free(old); }

(i.e. copy the file contents to the newly adjusted pointer, not to the pre-adjusted one) appears to fix it based on very brief testing, but I've no idea if this still works with unmmapping etc.

ssj-gz avatar Dec 30 '12 16:12 ssj-gz

Ah yes, I am writing the file data to the wrong place, silly me... :)

kripken avatar Dec 30 '12 20:12 kripken

Fixed on incoming, added a testcase. Please reopen or comment if it isn't resolved for your project.

kripken avatar Dec 30 '12 20:12 kripken