Has anyone encountered with this error?

Has anyone encountered with this error?
failed during stage ‘building site’: Build script returned non-zero exit code: 139

From a quick google search it means that the program crashed before it could exit, giving you this 139 error.

Do you have any other output from the logs?

What are you trying to deploy?

Our build image is a Linux system and in most cases an exit code of over 128 represents a process shutting down because of a signal it received from the operating system. There is info about this here:

  • (see the second answer)

Quoting part of the second answer (itself quoting the Advanced Bash Scripting Guide):

128+n: Fatal error signal “n”

So, for 139, this was signal 11 (because 139-128=11). Checking the signal manpage, (using man 7 signal) I see this:

SIGSEGV      11       Core    Invalid memory reference

So this appear to be a segmentation fault (aka segfault) during the build process.

Which static site generator are you using? Would you be willing to copy/paste the error message (and surrounding log lines for context) here?

I’m getting same error. I’m trying to deploy Gatsby site.
Here is the log.

2:41:06 AM: Build ready to start
2:41:08 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
2:41:08 AM: build-image tag: v3.3.2
2:41:08 AM: buildbot version: ef8d0929ed0baabafd8bbb7d0b021e1fc24180c0
2:41:08 AM: Fetching cached dependencies
2:41:08 AM: Starting to download cache of 161.1MB
2:41:10 AM: Finished downloading cache in 1.447227323s
2:41:10 AM: Starting to extract cache
2:41:16 AM: Finished extracting cache in 5.920107698s
2:41:16 AM: Finished fetching cache in 7.411024767s
2:41:16 AM: Starting to prepare the repo for build
2:41:16 AM: Preparing Git Reference refs/heads/master
2:41:17 AM: Starting build script
2:41:17 AM: Installing dependencies
2:41:17 AM: Started restoring cached node version
2:41:20 AM: Finished restoring cached node version
2:41:21 AM: v10.16.0 is already installed.
2:41:22 AM: Now using node v10.16.0 (npm v6.9.0)
2:41:22 AM: Attempting ruby version 2.6.2, read from environment
2:41:24 AM: Using ruby version 2.6.2
2:41:24 AM: Using PHP version 5.6
2:41:24 AM: Started restoring cached node modules
2:41:24 AM: Finished restoring cached node modules
2:41:25 AM: Installing NPM modules using NPM version 6.9.0
2:41:39 AM: npm
2:41:39 AM:  WARN ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
2:41:39 AM: npm
2:41:39 AM:  WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
2:41:39 AM: npm
2:41:39 AM:  WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:41:39 AM: removed 12 packages and audited 28295 packages in 13.211s
2:41:39 AM: found 735 high severity vulnerabilities
2:41:39 AM:   run `npm audit fix` to fix them, or `npm audit` for details
2:41:39 AM: NPM modules installed
2:41:39 AM: Started restoring cached go cache
2:41:39 AM: Finished restoring cached go cache
2:41:39 AM: unset GOOS;
2:41:39 AM: unset GOARCH;
2:41:39 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
2:41:39 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
2:41:39 AM: go version >&2;
2:41:39 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
2:41:39 AM: go version go1.12 linux/amd64
2:41:39 AM: Installing missing commands
2:41:39 AM: Verify run directory
2:41:39 AM: Executing user command: gatsby build
2:41:42 AM: success open and validate gatsby-configs — 0.004 s
2:41:43 AM: success load plugins — 1.038 s
2:41:43 AM: success onPreInit — 0.006 s
2:41:43 AM: success delete html and css files from previous builds — 0.007 s
2:41:43 AM: success initialize cache — 0.010 s
2:41:43 AM: success copy gatsby files — 0.027 s
2:41:43 AM: success onPreBootstrap — 0.013 s
2:41:43 AM: success source and transform nodes — 0.708 s
2:41:44 AM: success building schema — 0.285 s
2:41:44 AM: success createPages — 0.037 s
2:41:44 AM: success createPagesStatefully — 0.066 s
2:41:44 AM: success onPreExtractQueries — 0.002 s
2:41:44 AM: success update schema — 0.050 s
2:41:44 AM: success extract queries from components — 0.114 s
2:41:44 AM: success write out requires — 0.004 s
2:41:44 AM: success write out redirect data — 0.001 s
2:41:44 AM: success onPostBootstrap — 0.001 s
2:41:44 AM: info bootstrap finished - 4.816 s
2:41:45 AM: success run static queries — 1.093 s — 3/3 2.75 queries/second
2:41:54 AM: success Building production JavaScript and CSS bundles — 9.398 s
2:41:55 AM: success Rewriting compilation hashes — 0.002 s
2:41:55 AM: success run page queries — 0.087 s — 5/5 58.29 queries/second
2:42:36 AM: success Building static HTML for pages — 2.409 s — 5/5 20.31 pages/second
2:42:36 AM: info Done building in 56.427 sec
2:42:38 AM: (sharp:1224): GLib-CRITICAL **: 21:12:38.707: g_hash_table_lookup: assertion 'hash_table != NULL' failed
2:42:38 AM: (sharp:1224): GLib-CRITICAL **: 21:12:38.708: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
2:42:38 AM: (sharp:1224): GLib-CRITICAL **: 21:12:38.708: g_hash_table_lookup: assertion 'hash_table != NULL' failed
2:42:41 AM: /usr/local/bin/build: line 34:  1224 Segmentation fault      (core dumped) gatsby build
2:42:41 AM: Skipping functions preparation step: no functions directory set
2:42:41 AM: Caching artifacts
2:42:41 AM: Started saving node modules
2:42:41 AM: Finished saving node modules
2:42:41 AM: Started saving pip cache
2:42:41 AM: Finished saving pip cache
2:42:41 AM: Started saving emacs cask dependencies
2:42:41 AM: Finished saving emacs cask dependencies
2:42:41 AM: Started saving maven dependencies
2:42:41 AM: Finished saving maven dependencies
2:42:41 AM: Started saving boot dependencies
2:42:41 AM: Finished saving boot dependencies
2:42:41 AM: Started saving go dependencies
2:42:41 AM: Finished saving go dependencies
2:42:41 AM: Error running command: Build script returned non-zero exit code: 139
2:42:41 AM: failed during stage 'building site': Build script returned non-zero exit code: 139
2:42:41 AM: Failing build: Failed to build site
2:42:41 AM: Finished processing build request in 1m32.919917529s

This is almost certainly a memory overuse problem:

You’ll want to follow the advice in this article (specifically #5) about optimizing your site’s memory usage during build:

There are several gatsby plugins that are SUPER memory hungry and you need to be careful about using them on our build network unless you are an enterprise subscriber who can set custom build resources.

2 Likes

It helped me to solve the issue. It was certainly a large image size which was causing the problem. Thanks you @fool