Skip to content

Commit

Permalink
Print errno when mprotect fails
Browse files Browse the repository at this point in the history
Trying to figure out the problem on s390x.
  • Loading branch information
tenderlove committed Oct 20, 2021
1 parent 82e2443 commit 472c97b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4870,7 +4870,8 @@ lock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
#else
if (mprotect(body, HEAP_PAGE_SIZE, PROT_NONE)) {
#endif
rb_bug("Couldn't protect page %p", (void *)body);
int pagesize = (int)sysconf(_SC_PAGE_SIZE);
rb_bug("Couldn't protect page %p, page size: %d errno: %s", (void *)body, pagesize, strerror(errno));
}
else {
gc_report(5, objspace, "Protecting page in move %p\n", (void *)body);
Expand All @@ -4887,7 +4888,8 @@ unlock_page_body(rb_objspace_t *objspace, struct heap_page_body *body)
#else
if (mprotect(body, HEAP_PAGE_SIZE, PROT_READ | PROT_WRITE)) {
#endif
rb_bug("Couldn't unprotect page %p", (void *)body);
int pagesize = (int)sysconf(_SC_PAGE_SIZE);
rb_bug("Couldn't unprotect page %p, page size: %d errno: %s", (void *)body, pagesize, strerror(errno));
}
else {
gc_report(5, objspace, "Unprotecting page in move %p\n", (void *)body);
Expand Down

0 comments on commit 472c97b

Please sign in to comment.