Skip to content

Instantly share code, notes, and snippets.

@rubennorte
Last active July 18, 2017 15:34
Show Gist options
  • Save rubennorte/1ac1ed80ef3ef77d2aecc2335c1f59db to your computer and use it in GitHub Desktop.
Save rubennorte/1ac1ed80ef3ef77d2aecc2335c1f59db to your computer and use it in GitHub Desktop.

This gist reproduces a bug in Yarn v0.27.5.

The bug is caused by Yarn returning exit status 0 when a script inside the package.json "scripts" causes a segmentation fault.

This only happens when there is a single command in the script (e.g.: "test": "./segfault"). When there are several commands in the script (e.g.: "test-alt": "true && ./segfault") it returns an exit status 1.

This bug causes errors to be unnoticed in CI builds, where everything seems to be OK.

Steps to reproduce:

  1. Download the gist.
  2. Execute yarn run test ; echo "Exit status $?" to reproduce the issue.
  3. Execute yarn run test-alt ; echo "Exit status $?" to reproduce a workaround for the issue.
{
"name": "yarn-segfault",
"version": "1.0.0",
"scripts": {
"compile": "gcc segfault.c -g -o segfault",
"pretest": "yarn run compile",
"test": "./segfault",
"pretest-alt": "yarn run compile",
"test-alt": "true && ./segfault"
}
}
int main(void)
{
char *s = "hello world";
*s = 'H';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment