Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

munmap not delete the right address range #126

Open
DinoStray opened this issue Oct 12, 2020 · 0 comments · May be fixed by #127
Open

munmap not delete the right address range #126

DinoStray opened this issue Oct 12, 2020 · 0 comments · May be fixed by #127

Comments

@DinoStray
Copy link

DinoStray commented Oct 12, 2020

we use mmap map the whole file, and ret->data is only part of the file without ETHASH_DAG_MAGIC_NUM

static bool ethash_mmap(struct ethash_full* ret, FILE* f)
{
	int fd;
	char* mmapped_data;
	errno = 0;
	ret->file = f;
	if ((fd = ethash_fileno(ret->file)) == -1) {
		return false;
	}
	mmapped_data= mmap(
		NULL,
		(size_t)ret->file_size + ETHASH_DAG_MAGIC_NUM_SIZE,
		PROT_READ | PROT_WRITE,
		MAP_SHARED,
		fd,
		0
	);
	if (mmapped_data == MAP_FAILED) {
		return false;
	}
	ret->data = (node*)(mmapped_data + ETHASH_DAG_MAGIC_NUM_SIZE);
	return true;
}

finally we munmap the address only begin with ret->data, then munmap(..) != 0

munmap(full->data, (size_t)full->file_size);
@DinoStray DinoStray linked a pull request Oct 12, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant