Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sea: fix memory leak detected by asan #47309

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions src/node_sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <memory>
#include <string_view>
#include <tuple>
#include <vector>

#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)

Expand Down Expand Up @@ -60,19 +61,13 @@ std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv) {
// Repeats argv[0] at position 1 on argv as a replacement for the missing
// entry point file path.
if (IsSingleExecutable()) {
char** new_argv = new char*[argc + 2];
RaisinTen marked this conversation as resolved.
Show resolved Hide resolved
int new_argc = 0;
new_argv[new_argc++] = argv[0];
new_argv[new_argc++] = argv[0];

for (int i = 1; i < argc; ++i) {
new_argv[new_argc++] = argv[i];
}

new_argv[new_argc] = nullptr;

argc = new_argc;
argv = new_argv;
static std::vector<char*> new_argv;
new_argv.reserve(argc + 2);
new_argv.emplace_back(argv[0]);
new_argv.insert(new_argv.end(), argv, argv + argc);
new_argv.emplace_back(nullptr);
argc = new_argv.size() - 1;
argv = new_argv.data();
}

return {argc, argv};
Expand Down
5 changes: 0 additions & 5 deletions test/parallel/test-single-executable-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ if (!process.config.variables.single_executable_application)
if (!['darwin', 'win32', 'linux'].includes(process.platform))
common.skip(`Unsupported platform ${process.platform}.`);

if (process.platform === 'linux' && process.config.variables.asan) {
// Source of the memory leak - https://github.com/nodejs/node/blob/da0bc6db98cef98686122ea1e2cd2dbd2f52d123/src/node_sea.cc#L94.
common.skip('Running the resultant binary fails because of a memory leak ASAN error.');
}

if (process.platform === 'linux' && process.config.variables.is_debug === 1)
common.skip('Running the resultant binary fails with `Couldn\'t read target executable"`.');

Expand Down