Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using c8 node --test #432

Open
remcohaszing opened this issue Nov 25, 2022 · 6 comments
Open

Crash when using c8 node --test #432

remcohaszing opened this issue Nov 25, 2022 · 6 comments

Comments

@remcohaszing
Copy link

  • 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
@jamiehodge
Copy link

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

@bcoe
Copy link
Owner

bcoe commented Feb 14, 2023

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

@bcoe
Copy link
Owner

bcoe commented Feb 14, 2023

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

nodejs/node#45013

Could you try the latest release of Node.js?

@remcohaszing
Copy link
Author

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 added a commit to syntax-tree/hast-util-from-html-isomorphic that referenced this issue Mar 16, 2023
@anton-107
Copy link

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

@seriousme
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants