Skip to content

Commit

Permalink
src: fix largepages regression
Browse files Browse the repository at this point in the history
During the addition of macOS support for large pages, a `memcpy` ended
up under the wrong preprocessor directive. As a result, the newly
allocated large pages were not initialized with a copy of the text
section.

Thanks to Suresh Srinivas <suresh.srinivas@intel.com>!

PR-URL: nodejs#29914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
  • Loading branch information
Gabriel Schulhof committed Mar 5, 2020
1 parent 01de6c2 commit 2b373bd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/large_pages/node_large_page.cc
Expand Up @@ -366,6 +366,7 @@ MoveTextRegionToLargePages(const text_region& r) {
}
return -1;
}
memcpy(start, nmem, size);
#elif defined(__FreeBSD__)
tmem = mmap(start, size,
PROT_READ | PROT_WRITE | PROT_EXEC,
Expand Down Expand Up @@ -400,8 +401,6 @@ MoveTextRegionToLargePages(const text_region& r) {
return -1;
}
memcpy(start, tmem, size);
#else
memcpy(start, nmem, size);
#endif

ret = mprotect(start, size, PROT_READ | PROT_EXEC);
Expand Down

0 comments on commit 2b373bd

Please sign in to comment.