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 5a51edd

Browse filesBrowse files
skomskirvagg
authored andcommitted
build: add --enable-asan with builtin leakcheck
PR-URL: #2376 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 7be4e49 commit 5a51edd
Copy full SHA for 5a51edd

File tree

Expand file treeCollapse file tree

5 files changed

+46
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+46
-3
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+20-2Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,34 @@
173173
},
174174
'msvs_disabled_warnings': [4351, 4355, 4800],
175175
'conditions': [
176-
['asan != 0', {
176+
['asan == 1 and OS != "mac"', {
177177
'cflags+': [
178178
'-fno-omit-frame-pointer',
179179
'-fsanitize=address',
180-
'-w', # http://crbug.com/162783
180+
'-DLEAK_SANITIZER'
181181
],
182182
'cflags_cc+': [ '-gline-tables-only' ],
183183
'cflags!': [ '-fomit-frame-pointer' ],
184184
'ldflags': [ '-fsanitize=address' ],
185185
}],
186+
['asan == 1 and OS == "mac"', {
187+
'xcode_settings': {
188+
'OTHER_CFLAGS+': [
189+
'-fno-omit-frame-pointer',
190+
'-gline-tables-only',
191+
'-fsanitize=address',
192+
'-DLEAK_SANITIZER'
193+
],
194+
'OTHER_CFLAGS!': [
195+
'-fomit-frame-pointer',
196+
],
197+
},
198+
'target_conditions': [
199+
['_type!="static_library"', {
200+
'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
201+
}],
202+
],
203+
}],
186204
['OS == "win"', {
187205
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
188206
'defines': [
Collapse file

‎configure‎

Copy file name to clipboardExpand all lines: configure
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ parser.add_option('--xcode',
335335
dest='use_xcode',
336336
help='generate build files for use with xcode')
337337

338+
parser.add_option('--enable-asan',
339+
action='store_true',
340+
dest='enable_asan',
341+
help='build with asan')
342+
338343
parser.add_option('--enable-static',
339344
action='store_true',
340345
dest='enable_static',
@@ -707,6 +712,7 @@ def configure_node(o):
707712
if options.linked_module:
708713
o['variables']['library_files'] = options.linked_module
709714

715+
o['variables']['asan'] = int(options.enable_asan or 0)
710716

711717
def configure_library(lib, output):
712718
shared_lib = 'shared_' + lib
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#include <string.h>
5353
#include <sys/types.h>
5454

55+
#if defined(LEAK_SANITIZER)
56+
#include <sanitizer/lsan_interface.h>
57+
#endif
58+
5559
#if defined(_MSC_VER)
5660
#include <direct.h>
5761
#include <io.h>
@@ -3967,6 +3971,10 @@ static void StartNodeInstance(void* arg) {
39673971
instance_data->set_exit_code(exit_code);
39683972
RunAtExit(env);
39693973

3974+
#if defined(LEAK_SANITIZER)
3975+
__lsan_do_leak_check();
3976+
#endif
3977+
39703978
env->Dispose();
39713979
env = nullptr;
39723980
}
Collapse file

‎test/sequential/test-child-process-emfile.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-child-process-emfile.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ if (common.isWindows) {
99
return;
1010
}
1111

12+
var openFds = [];
13+
1214
for (;;) {
1315
try {
14-
fs.openSync(__filename, 'r');
16+
openFds.push(fs.openSync(__filename, 'r'));
1517
} catch (err) {
1618
assert(err.code === 'EMFILE' || err.code === 'ENFILE');
1719
break;
@@ -27,3 +29,8 @@ proc.on('error', common.mustCall(function(err) {
2729

2830
// 'exit' should not be emitted, the process was never spawned.
2931
proc.on('exit', assert.fail);
32+
33+
// close one fd for LSan
34+
if (openFds.length >= 1) {
35+
fs.closeSync(openFds.pop());
36+
}
Collapse file

‎tools/lsan_suppressions.txt‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Usage: LSAN_OPTIONS=suppressions=`pwd`/tools/lsan_suppressions.txt make check
2+
3+
# Suppress small (intentional) leaks in glibc
4+
leak:libc.so

0 commit comments

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