c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Crash when using `c8 node --test`

Open remcohaszing opened this issue 2 years ago • 6 comments

  • Version: 7.12.0
  • Platform: Node.js v18.12.1

Running node --test works fine. Running c8 node tests/*.test.js works fine too. However, running c8 node --test causes a segmentation fault.

$ c8 node --test
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
[1]    71112 segmentation fault (core dumped)  c8 node --test

remcohaszing avatar Nov 25 '22 15:11 remcohaszing

Would someone please take a look at this? It's blocking usage of c8 for newer node versions.

jamiehodge avatar Jan 23 '23 10:01 jamiehodge

@remcohaszing would you be able to provide a minimal reproduction that demonstrates this behaviour?

bcoe avatar Feb 14 '23 20:02 bcoe

@jamiehodge @remcohaszing actually, I think this might relate to:

https://github.com/nodejs/node/issues/45013

Could you try the latest release of Node.js?

bcoe avatar Feb 14 '23 21:02 bcoe

I am still able to reproduce this using Node.js 16.19.0 (in Docker), but not with Node.js 18.14.0 (in Docker) or 19.6.1 (Linux host machine).

This gives me the impression this is caused by a bug in Node.js that has been fixed in the version 18 releases, but has not been backported into Node.js 16.

I used these test files:

// package.json
{
  "type": "module",
  "dependencies": {
    "c8": "7.13.0"
  }
}
// index.js
export const bool = true
// test.js
import assert from 'node:assert/strict'
import { test } from 'node:test'

import { bool } from './index.js'

test('coverage', () => {
  assert.ok(bool)
})

remcohaszing avatar Feb 17 '23 13:02 remcohaszing

I have fixed my issue by moving to node:20 image in my github actions

anton-107 avatar Jun 05 '23 14:06 anton-107

Same issue here:

import { test } from "node:test";
import { strict as assert } from "node:assert/strict";

test("crash test", () => {
	assert.equal(true, true);
});

Results in:

c8 node --test crash-test.js 
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------
Segmentation fault (core dumped)

Test runs ok on Node 18 and Node 20

It really depends on the --test option, as without that option it runs fine on Node 16.

c8 node crash-test.js 
(node:25295) ExperimentalWarning: The test runner is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TAP version 13
# Subtest: crash test
ok 1 - crash test
  ---
  duration_ms: 3.053627
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 16.969626
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

Hope this helps. (and else we need to wait for September 11 when Node 16 will be end of life anyway ;-))

Hans

seriousme avatar Jun 11 '23 06:06 seriousme