Skip to content
Browse files

src: readlink("/proc/self/exe") -> uv_exename()

This commit also adds error handling. A THP-enabled build terminated
with an out-of-memory error on a system without /proc because it cast
the -1 from readlink() to size_t (i.e. ULONG_MAX) and then tried to
allocate a string of that size.

PR-URL: #28333
Reviewed-By: Rich Trott <>
Reviewed-By: Colin Ihrig <>
Reviewed-By: James M Snell <>
Reviewed-By: Anna Henningsen <>
  • Loading branch information...
bnoordhuis authored and targos committed Jun 21, 2019
1 parent a28db5f commit 32cf344f8e7c5ae3c549de68c369de66c960a112
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/large_pages/
@@ -115,8 +115,12 @@ static struct text_region FindNodeTextRegion() {
std::string exename;
char selfexe[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", selfexe, PATH_MAX);
exename = std::string(selfexe, count);

size_t size = sizeof(selfexe);
if (uv_exepath(selfexe, &size))
return nregion;

exename = std::string(selfexe, size);

while (std::getline(ifs, map_line)) {

0 comments on commit 32cf344

Please sign in to comment.
You can’t perform that action at this time.