-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for io.js and improved stack guard
In some pathological cases you could corrupt the stack using fibers and cause a segfault. There seem to be some changes to how the stack guard works from v8 3.14.x (node 0.10.x) to 3.28.x (node 0.12.x). This was causing a lot of confusion so I brushed the problem under the rug a little bit.
- Loading branch information
Showing
3 changed files
with
85 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var Fiber = require('fibers'); | ||
|
||
// Create a bunch of fibers and consume each fiber's stack, then yield | ||
var fibers = []; | ||
for (var ii = 0; ii < 100; ++ii) { | ||
var fiber; | ||
fibers.push(fiber = Fiber(function() { | ||
var caught = false; | ||
var recur = 0, stop; | ||
function foo() { | ||
++recur; | ||
try { | ||
foo(); | ||
} catch (err) { | ||
if (!caught) { | ||
stop = recur - 500; | ||
caught = true; | ||
} else if (stop === recur) { | ||
process.stdout.write(''); // do a thing? | ||
return Fiber.yield(); | ||
} | ||
--recur; | ||
throw err; | ||
} | ||
} | ||
foo(); | ||
})); | ||
fiber.run(); | ||
} | ||
|
||
// Unwind started fibers | ||
fibers.forEach(function(fiber) { | ||
fiber.run(); | ||
}); | ||
|
||
console.log('pass'); |