Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45c5ad7

Browse filesBrowse files
Gabriel Schulhoftargos
authored andcommitted
src: refine maps parsing for large pages
Multiple sections may be marked as "r-xp" and with the executable's path. We use the location of the `__nodetext` symbol added by the linker script to ensure that the range we retrieve from the maps file does indeed contain the Node.js text section. Thanks to Suresh Srinivas <suresh.srinivas@intel.com>! PR-URL: #29973 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent 3e39909 commit 45c5ad7
Copy full SHA for 45c5ad7

File tree

Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed
Open diff view settings
Collapse file

‎src/large_pages/node_large_page.cc‎

Copy file name to clipboardExpand all lines: src/large_pages/node_large_page.cc
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ static void PrintSystemError(int error) {
8383
return;
8484
}
8585

86-
inline int64_t hugepage_align_up(int64_t addr) {
86+
inline uintptr_t hugepage_align_up(uintptr_t addr) {
8787
return (((addr) + (hps) - 1) & ~((hps) - 1));
8888
}
8989

90-
inline int64_t hugepage_align_down(int64_t addr) {
90+
inline uintptr_t hugepage_align_down(uintptr_t addr) {
9191
return ((addr) & ~((hps) - 1));
9292
}
9393

@@ -103,7 +103,7 @@ static struct text_region FindNodeTextRegion() {
103103
std::string permission;
104104
std::string dev;
105105
char dash;
106-
int64_t start, end, offset, inode;
106+
uintptr_t start, end, offset, inode;
107107
struct text_region nregion;
108108

109109
nregion.found_text_region = false;
@@ -138,18 +138,20 @@ static struct text_region FindNodeTextRegion() {
138138
std::string pathname;
139139
iss >> pathname;
140140
if (pathname == exename && permission == "r-xp") {
141-
start = reinterpret_cast<uint64_t>(&__nodetext);
142-
char* from = reinterpret_cast<char*>(hugepage_align_up(start));
143-
char* to = reinterpret_cast<char*>(hugepage_align_down(end));
144-
145-
if (from < to) {
146-
size_t size = to - from;
147-
nregion.found_text_region = true;
148-
nregion.from = from;
149-
nregion.to = to;
150-
nregion.total_hugepages = size / hps;
141+
uintptr_t ntext = reinterpret_cast<uintptr_t>(&__nodetext);
142+
if (ntext >= start && ntext < end) {
143+
char* from = reinterpret_cast<char*>(hugepage_align_up(ntext));
144+
char* to = reinterpret_cast<char*>(hugepage_align_down(end));
145+
146+
if (from < to) {
147+
size_t size = to - from;
148+
nregion.found_text_region = true;
149+
nregion.from = from;
150+
nregion.to = to;
151+
nregion.total_hugepages = size / hps;
152+
}
153+
break;
151154
}
152-
break;
153155
}
154156
}
155157
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.