Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant