@@ -176,11 +176,9 @@ namespace detail {
176
176
int mprotect_page_and_return_old_protections (void * page, int page_size, int protections) {
177
177
DWORD old_protections;
178
178
if (!VirtualProtect (page, page_size, protections, &old_protections)) {
179
- throw std::runtime_error (
180
- microfmt::format (
181
- " VirtualProtect call failed: {}" ,
182
- std::system_error (GetLastError (), std::system_category ()).what ()
183
- )
179
+ throw internal_error (
180
+ " VirtualProtect call failed: {}" ,
181
+ std::system_error (GetLastError (), std::system_category ()).what ()
184
182
);
185
183
}
186
184
return old_protections;
@@ -191,11 +189,9 @@ namespace detail {
191
189
void * allocate_page (int page_size) {
192
190
auto page = VirtualAlloc (nullptr , page_size, MEM_COMMIT | MEM_RESERVE, memory_readwrite);
193
191
if (!page) {
194
- throw std::runtime_error (
195
- microfmt::format (
196
- " VirtualAlloc call failed: {}" ,
197
- std::system_error (GetLastError (), std::system_category ()).what ()
198
- )
192
+ throw internal_error (
193
+ " VirtualAlloc call failed: {}" ,
194
+ std::system_error (GetLastError (), std::system_category ()).what ()
199
195
);
200
196
}
201
197
return page;
@@ -240,7 +236,7 @@ namespace detail {
240
236
&object
241
237
);
242
238
if (status == KERN_INVALID_ADDRESS) {
243
- throw std::runtime_error (" vm_region failed with KERN_INVALID_ADDRESS" );
239
+ throw internal_error (" vm_region failed with KERN_INVALID_ADDRESS" );
244
240
}
245
241
int perms = 0 ;
246
242
if (info.protection & VM_PROT_READ) {
@@ -303,13 +299,13 @@ namespace detail {
303
299
return nullopt;
304
300
}
305
301
if (stream.fail ()) {
306
- throw std::runtime_error (" Failure reading /proc/self/maps" );
302
+ throw internal_error (" Failure reading /proc/self/maps" );
307
303
}
308
304
stream.ignore (1 ); // space
309
305
char r, w, x; // there's a private/shared flag after these but we don't need it
310
306
stream>>r>>w>>x;
311
307
if (stream.fail () || stream.eof ()) {
312
- throw std::runtime_error (" Failure reading /proc/self/maps" );
308
+ throw internal_error (" Failure reading /proc/self/maps" );
313
309
}
314
310
int perms = 0 ;
315
311
if (r == ' r' ) {
@@ -388,7 +384,7 @@ namespace detail {
388
384
#endif
389
385
void mprotect_page (void * page, int page_size, int protections) {
390
386
if (mprotect (page, page_size, protections) != 0 ) {
391
- throw std::runtime_error ( microfmt::format ( " mprotect call failed: {}" , strerror (errno) ));
387
+ throw internal_error ( " mprotect call failed: {}" , strerror (errno));
392
388
}
393
389
}
394
390
int mprotect_page_and_return_old_protections (void * page, int page_size, int protections) {
@@ -399,7 +395,7 @@ namespace detail {
399
395
void * allocate_page (int page_size) {
400
396
auto page = mmap (nullptr , page_size, memory_readwrite, MAP_ANONYMOUS | MAP_PRIVATE, -1 , 0 );
401
397
if (page == MAP_FAILED) {
402
- throw std::runtime_error ( microfmt::format ( " mmap call failed: {}" , strerror (errno) ));
398
+ throw internal_error ( " mmap call failed: {}" , strerror (errno));
403
399
}
404
400
return page;
405
401
}
@@ -445,9 +441,7 @@ namespace detail {
445
441
// shouldn't be anything other than 4096 but out of an abundance of caution
446
442
auto page_size = get_page_size ();
447
443
if (page_size <= 0 && (page_size & (page_size - 1 )) != 0 ) {
448
- throw std::runtime_error (
449
- microfmt::format (" getpagesize() is not a power of 2 greater than zero (was {})" , page_size)
450
- );
444
+ throw internal_error (" getpagesize() is not a power of 2 greater than zero (was {})" , page_size);
451
445
}
452
446
453
447
// allocate a page for the new vtable so it can be made read-only later
@@ -467,7 +461,7 @@ namespace detail {
467
461
auto page_addr = type_info_addr & ~(page_size - 1 );
468
462
// make sure the memory we're going to set is within the page
469
463
if (type_info_addr - page_addr + sizeof (void *) > static_cast <unsigned >(page_size)) {
470
- throw std::runtime_error (" pointer crosses page boundaries" );
464
+ throw internal_error (" pointer crosses page boundaries" );
471
465
}
472
466
auto old_protections = mprotect_page_and_return_old_protections (
473
467
reinterpret_cast <void *>(page_addr),
0 commit comments