File tree 3 files changed +45
-0
lines changed
test/addons/cpu-profiler-crash
3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include " node.h"
2
+ #include " v8.h"
3
+ #include " v8-profiler.h"
4
+
5
+ static void StartCpuProfiler (const v8::FunctionCallbackInfo<v8::Value>& args) {
6
+ v8::CpuProfiler* profiler = v8::CpuProfiler::New (args.GetIsolate ());
7
+ v8::Local<v8::String> profile_title = v8::String::NewFromUtf8 (
8
+ args.GetIsolate (),
9
+ " testing" ,
10
+ v8::NewStringType::kInternalized ).ToLocalChecked ();
11
+ profiler->StartProfiling (profile_title, true );
12
+ }
13
+
14
+ NODE_MODULE_INIT (/* exports, module, context */ ) {
15
+ NODE_SET_METHOD (exports, " startCpuProfiler" , StartCpuProfiler);
16
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ 'targets' : [
3
+ {
4
+ 'target_name' : 'binding' ,
5
+ 'sources' : [ 'binding.cc' ],
6
+ 'includes' : ['../common.gypi' ],
7
+ }
8
+ ]
9
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ // This test crashes most of the time unless the v8 patch:
4
+ // https://github.com/v8/v8/commit/beebee4f80ff2eb91187ef1e8fa00b8ff82a20b3
5
+ // is applied.
6
+ const common = require ( '../../common' ) ;
7
+ const bindings = require ( `./build/${ common . buildType } /binding` ) ;
8
+
9
+ function fn ( ) { setImmediate ( fn ) ; }
10
+ setInterval ( function ( ) {
11
+ for ( let i = 0 ; i < 1000000 ; i ++ )
12
+ fn ( ) ;
13
+ clearInterval ( this ) ;
14
+ setTimeout ( process . reallyExit , 2000 ) ;
15
+ } , 0 ) ;
16
+
17
+
18
+ setTimeout ( ( ) => {
19
+ bindings . startCpuProfiler ( ) ;
20
+ } , 1000 ) ;
You can’t perform that action at this time.
0 commit comments