this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Minor libgmalloc fixes

+8 -17
-4
src/libgmalloc/CMakeLists.txt
··· 1 1 project(libgmalloc) 2 2 3 - include_directories( 4 - ${CMAKE_SOURCE_DIR}/src/dyld/include 5 - ) 6 - 7 3 set(libgmalloc_sources 8 4 gmalloc.c 9 5 )
+8 -13
src/libgmalloc/gmalloc.c
··· 58 58 } 59 59 60 60 static void *do_alloc(size_t payload_size, size_t align) { 61 - if (align > vm_page_size) { 62 - // We don't support this. 63 - align = vm_page_size; 64 - } 65 - 66 61 // Decide how much memory we're going to allocate, 67 62 // not counting the guard page. 68 63 size_t accessible_size = round_up(payload_size, align); ··· 116 111 if (ptr == NULL) { 117 112 int saved_errno = errno; 118 113 const char msg[] = "Failed to alloc: "; 119 - write(2, msg, sizeof(msg)); 114 + write(2, msg, sizeof(msg) - 1); 120 115 // Do not use strerror(), because it allocates. 121 116 extern const char *const sys_errlist[]; 122 117 write(2, sys_errlist[saved_errno], strlen(sys_errlist[saved_errno])); ··· 147 142 return ptr; 148 143 } 149 144 150 - static void check_header(const struct gmalloc_header *header) { 145 + static void unlock_and_check_header(const struct gmalloc_header *header) { 146 + if (gmalloc_protect_before && !gmalloc_allow_reads) { 147 + mprotect(round_down((void *) header, vm_page_size), vm_page_size, PROT_READ); 148 + } 149 + 151 150 if (!gmalloc_check_header) { 152 151 return; 153 152 } 154 153 155 - if (gmalloc_protect_before && !gmalloc_allow_reads) { 156 - mprotect(round_down((void *) header, vm_page_size), vm_page_size, PROT_READ); 157 - } 158 - 159 154 if (header->magic != GMALLOC_MAGIC || header->magic_again != GMALLOC_MAGIC) { 160 155 abort(); 161 156 } ··· 167 162 } 168 163 169 164 struct gmalloc_header *header = header_for_ptr(ptr); 170 - check_header(header); 165 + unlock_and_check_header(header); 171 166 172 167 munmap(header->mmap_base, header->mmap_size); 173 168 } ··· 178 173 size_to_copy = 0; 179 174 } else { 180 175 struct gmalloc_header *header = header_for_ptr(old_ptr); 181 - check_header(header); 176 + unlock_and_check_header(header); 182 177 size_to_copy = header->size; 183 178 } 184 179 if (size_to_copy > new_size) {