This repository was archived by the owner on Jun 18, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Support for node-report on native sigsegv/sigill/sigfpe #92
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
| 'use strict'; | ||
|
|
||
| // Testcase to produce report on native crash (sigfpe) | ||
|
|
||
| // This testcase uses process.kill() to raise the sigfpe signal rather than | ||
| // producing a real arithmetic exception (which would require native code). The | ||
| // code exercised in node-report is the same. | ||
|
|
||
| if (process.argv[2] === 'child') { | ||
| // Child process implementation | ||
| require('../'); | ||
| process.kill(process.pid, 'SIGFPE'); | ||
|
|
||
| } else { | ||
| // Parent process implementation | ||
| const common = require('./common.js'); | ||
| const spawn = require('child_process').spawn; | ||
| const tap = require('tap'); | ||
| const fs = require('fs'); | ||
|
|
||
| if (common.isWindows()) { | ||
| tap.fail('Native crash support not available on Windows', { skip: true }); | ||
| return; | ||
| } | ||
|
|
||
| const child = spawn(process.execPath, [__filename, 'child']); | ||
|
|
||
| // Capture stderr output from the child process | ||
| var stderr = ''; | ||
| child.stderr.on('data', (chunk) => {stderr += chunk;}); | ||
|
|
||
| // Validation on child exit | ||
| child.on('exit', (code) => { | ||
| tap.plan(4); | ||
| tap.notEqual(code, 1, 'Check for expected non-zero exit code'); | ||
| const reports = common.findReports(child.pid); | ||
| tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
| const report = reports[0]; | ||
|
|
||
| // Testcase-specific report validation | ||
| fs.readFile(report, (err, data) => { | ||
| const headerSection = common.getSection(data, 'Node Report'); | ||
| tap.match(headerSection, /SIGFPE/, | ||
| 'Checking that header section contains crash signal name'); | ||
| }); | ||
| // Common report validation | ||
| const options = {pid: child.pid, commandline: child.spawnargs.join(' ')}; | ||
| common.validate(tap, report, options); | ||
| }); | ||
| } |
This file contains hidden or 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,50 @@ | ||
| 'use strict'; | ||
|
|
||
| // Testcase to produce report on native crash (sigill) | ||
|
|
||
| // This testcase uses process.kill() to raise the sigill signal rather than | ||
| // executing a real illegal instruction (which would require native code). The | ||
| // code exercised in node-report is the same. | ||
|
|
||
| if (process.argv[2] === 'child') { | ||
| // Child process implementation | ||
| require('../'); | ||
| process.kill(process.pid, 'SIGILL'); | ||
|
|
||
| } else { | ||
| // Parent process implementation | ||
| const common = require('./common.js'); | ||
| const spawn = require('child_process').spawn; | ||
| const tap = require('tap'); | ||
| const fs = require('fs'); | ||
|
|
||
| if (common.isWindows()) { | ||
| tap.fail('Native crash support not available on Windows', { skip: true }); | ||
| return; | ||
| } | ||
|
|
||
| const child = spawn(process.execPath, [__filename, 'child']); | ||
|
|
||
| // Capture stderr output from the child process | ||
| var stderr = ''; | ||
| child.stderr.on('data', (chunk) => {stderr += chunk;}); | ||
|
|
||
| // Validation on child exit | ||
| child.on('exit', (code) => { | ||
| tap.plan(4); | ||
| tap.notEqual(code, 1, 'Check for expected non-zero exit code'); | ||
| const reports = common.findReports(child.pid); | ||
| tap.equal(reports.length, 1, 'Found reports ' + reports); | ||
| const report = reports[0]; | ||
|
|
||
| // Testcase-specific report validation | ||
| fs.readFile(report, (err, data) => { | ||
| const headerSection = common.getSection(data, 'Node Report'); | ||
| tap.match(headerSection, /SIGILL/, | ||
| 'Checking that header section contains crash signal name'); | ||
| }); | ||
| // Common report validation | ||
| const options = {pid: child.pid, commandline: child.spawnargs.join(' ')}; | ||
| common.validate(tap, report, options); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd drop the superfluous parens. If you make a typo and write
info->si_pid = 0instead, then gcc won't complain because it thinks the assignment is intentional.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way of policing that typo is to put the constant on the LHS, eg
if (0 == info->si_pid), but I prefer readability.