Commit d21b098f authored by Marius Wachtler's avatar Marius Wachtler

Correctly align pointers inside registerPotentialRootRange

this showed up while importing a C extension
parent 6b573081
...@@ -312,12 +312,16 @@ void deregisterPermanentRoot(void* obj) { ...@@ -312,12 +312,16 @@ void deregisterPermanentRoot(void* obj) {
void registerPotentialRootRange(void* start, void* end) { void registerPotentialRootRange(void* start, void* end) {
// only track void* aligned memory // only track void* aligned memory
uintptr_t start_int = (uintptr_t)start;
uintptr_t end_int = (uintptr_t)end; uintptr_t end_int = (uintptr_t)end;
end_int = (end_int + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1); start_int = (start_int + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1);
end_int -= end_int % sizeof(void*); end_int -= end_int % sizeof(void*);
if (end_int > (uintptr_t)start) assert(start_int % sizeof(void*) == 0);
potential_root_ranges.push_back(std::make_pair(start, (void*)end_int)); assert(end_int % sizeof(void*) == 0);
if (end_int > start_int)
potential_root_ranges.push_back(std::make_pair((void*)start_int, (void*)end_int));
} }
extern "C" PyObject* PyGC_AddRoot(PyObject* obj) noexcept { extern "C" PyObject* PyGC_AddRoot(PyObject* obj) noexcept {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment