Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Incoming mmap alignment changes breaks reading from mmap'd file #769

ssj-gz opened this Issue Dec 30, 2012 · 2 comments


None yet
2 participants

ssj-gz commented Dec 30, 2012

Me again ;)

9f8132c 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);

(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.


kripken commented Dec 30, 2012

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


kripken commented Dec 30, 2012

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

@ssj-gz ssj-gz closed this Dec 31, 2012

@kripken kripken added a commit that referenced this issue Dec 31, 2012

@kripken kripken fix mmap; fixes #769 b500e12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment