Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fixed style and added regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmelikyan committed Jun 8, 2015
1 parent e5d442a commit 172f9c3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
3 changes: 1 addition & 2 deletions deps/v8/src/sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
// ISSUE-14576: To avoid deadlock, return if there is a thread lock
if (Isolate::GetProcessWideMutex().Pointer()->TryLock()) {
Isolate::GetProcessWideMutex().Pointer()->Unlock();
}
else {
} else {
return;
}

Expand Down
47 changes: 47 additions & 0 deletions test/simple/test-regress-GH-14576.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

/*
* Tests for sampler deadlock regression.
* Issue https://github.com/joyent/node/issues/14576
*/

var assert = require('assert');
var cp = require('child_process');

var child = undefined;

var deadlockTimer = setTimeout(function() {
if(child) {
process.kill(child.pid, 'SIGKILL');
}

assert(false, 'Node.js process hung');
}, 10000);

var testScript = "var i = 0; function r() { if(i++ > 2000) return; setTimeout(r, 1); }; r();";
var child = cp.exec(process.execPath + ' --prof -e "' + testScript + '"', function(err, stdout, stderr) {
clearTimeout(deadlockTimer);
assert.ifError(err);

// no process hanging, test passed
});

0 comments on commit 172f9c3

Please sign in to comment.