| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,16 +173,34 @@ | |||
| 173 | 173 | }, | |
| 174 | 174 | 'msvs_disabled_warnings': [4351, 4355, 4800], | |
| 175 | 175 | 'conditions': [ | |
| 176 | - ['asan != 0', { | ||
| 176 | + ['asan == 1 and OS != "mac"', { | ||
| 177 | 177 | 'cflags+': [ | |
| 178 | 178 | '-fno-omit-frame-pointer', | |
| 179 | 179 | '-fsanitize=address', | |
| 180 | - '-w', # http://crbug.com/162783 | ||
| 180 | + '-DLEAK_SANITIZER' | ||
| 181 | 181 | ], | |
| 182 | 182 | 'cflags_cc+': [ '-gline-tables-only' ], | |
| 183 | 183 | 'cflags!': [ '-fomit-frame-pointer' ], | |
| 184 | 184 | 'ldflags': [ '-fsanitize=address' ], | |
| 185 | 185 | }], | |
| 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 | + }], | ||
| 186 | 204 | ['OS == "win"', { | |
| 187 | 205 | 'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin | |
| 188 | 206 | 'defines': [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,6 +335,11 @@ parser.add_option('--xcode', | |||
| 335 | 335 | dest='use_xcode', | |
| 336 | 336 | help='generate build files for use with xcode') | |
| 337 | 337 | ||
| 338 | + parser.add_option('--enable-asan', | ||
| 339 | + action='store_true', | ||
| 340 | + dest='enable_asan', | ||
| 341 | + help='build with asan') | ||
| 342 | + | ||
| 338 | 343 | parser.add_option('--enable-static', | |
| 339 | 344 | action='store_true', | |
| 340 | 345 | dest='enable_static', | |
@@ -707,6 +712,7 @@ def configure_node(o): | |||
| 707 | 712 | if options.linked_module: | |
| 708 | 713 | o['variables']['library_files'] = options.linked_module | |
| 709 | 714 | ||
| 715 | + o['variables']['asan'] = int(options.enable_asan or 0) | ||
| 710 | 716 | ||
| 711 | 717 | def configure_library(lib, output): | |
| 712 | 718 | shared_lib = 'shared_' + lib | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,10 @@ | |||
| 52 | 52 | #include <string.h> | |
| 53 | 53 | #include <sys/types.h> | |
| 54 | 54 | ||
| 55 | + #if defined(LEAK_SANITIZER) | ||
| 56 | + #include <sanitizer/lsan_interface.h> | ||
| 57 | + #endif | ||
| 58 | + | ||
| 55 | 59 | #if defined(_MSC_VER) | |
| 56 | 60 | #include <direct.h> | |
| 57 | 61 | #include <io.h> | |
@@ -3967,6 +3971,10 @@ static void StartNodeInstance(void* arg) { | |||
| 3967 | 3971 | instance_data->set_exit_code(exit_code); | |
| 3968 | 3972 | RunAtExit(env); | |
| 3969 | 3973 | ||
| 3974 | + #if defined(LEAK_SANITIZER) | ||
| 3975 | + __lsan_do_leak_check(); | ||
| 3976 | + #endif | ||
| 3977 | + | ||
| 3970 | 3978 | env->Dispose(); | |
| 3971 | 3979 | env = nullptr; | |
| 3972 | 3980 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,9 +9,11 @@ if (common.isWindows) { | |||
| 9 | 9 | return; | |
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | + var openFds = []; | ||
| 13 | + | ||
| 12 | 14 | for (;;) { | |
| 13 | 15 | try { | |
| 14 | - fs.openSync(__filename, 'r'); | ||
| 16 | + openFds.push(fs.openSync(__filename, 'r')); | ||
| 15 | 17 | } catch (err) { | |
| 16 | 18 | assert(err.code === 'EMFILE' || err.code === 'ENFILE'); | |
| 17 | 19 | break; | |
@@ -27,3 +29,8 @@ proc.on('error', common.mustCall(function(err) { | |||
| 27 | 29 | ||
| 28 | 30 | // 'exit' should not be emitted, the process was never spawned. | |
| 29 | 31 | proc.on('exit', assert.fail); | |
| 32 | + | ||
| 33 | + // close one fd for LSan | ||
| 34 | + if (openFds.length >= 1) { | ||
| 35 | + fs.closeSync(openFds.pop()); | ||
| 36 | + } | ||
| Original file line number | Diff line number | Diff 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 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments