gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

gatsby v4.15 and above caused segment fault #35837

Closed kxxt closed 2 years ago

kxxt commented 2 years ago

Preliminary Checks

Description

After upgrading to gatsby v4.15, I encountered a segmentation fault error while running gatsby develop. (v4.14 works fine for me)

(gatsby@next has this issue, too)

I used segfault-handler to locate where the SEGSEGV came from by adding the following lines to gatsby-node.js

var SegfaultHandler = require('segfault-handler');
SegfaultHandler.registerHandler("crash.log");

It seems that it is related to lmdb(which I am unfamiliar with).

[                            ]   1.618 s 0/3 0% run page queries
PID 17587 received SIGSEGV for address: 0x0
/mnt/data/Repos/Mine/kxxt-website/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x327d)[0x7fe3c180727d]
/usr/lib/libc.so.6(+0x3e8e0)[0x7fe3c41138e0]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x800f0)[0x7fe3c18ab0f0]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x86eff)[0x7fe3c18b1eff]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x89810)[0x7fe3c18b4810]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x8b7f6)[0x7fe3c18b67f6]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x8f3e8)[0x7fe3c18ba3e8]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x67eba)[0x7fe3c1892eba]
/mnt/data/Repos/Mine/kxxt-website/node_modules/lmdb-linux-x64/node.napi.glibc.node(+0x6fcfb)[0x7fe3c189acfb]
/home/kxxt/.nvm/versions/node/v16.15.1/bin/node[0xab45dd]
/home/kxxt/.nvm/versions/node/v16.15.1/bin/node[0xd561ce]
/home/kxxt/.nvm/versions/node/v16.15.1/bin/node(_ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE+0x107)[0xd56797]
/home/kxxt/.nvm/versions/node/v16.15.1/bin/node[0x15f2199]
error Command failed with signal "SIGSEGV".

Reproduction Link

Unfortunately, I failed to make a minimal reproduction.

Steps to Reproduce

I failed to make a minimal reproduction and I also noticed that this issue didn't happen on netlify.

Maybe I can supply a minimal reproduction later.

My repo(not a minimal reproduction): https://github.com/kxxt/kxxt-website

Expected Result

The development server starts successfully.

Actual Result

The development server crashed due to a segmentation fault.

Here is the log:

yarn run v1.22.19
$ gatsby develop --verbose
verbose set gatsby_log_level: "verbose"
verbose set gatsby_executing_command: "develop"
verbose loading local command from:
/mnt/data/Repos/Mine/kxxt-website/node_modules/gatsby/dist/commands/develop.js
verbose running command: develop

verbose Transition to "initializing"
success compile gatsby files - 19.908s
success load gatsby config - 1.138s
success load plugins - 6.262s
success onPreInit - 0.020s
info One or more of your plugins have changed since the last time you ran Gatsby. As
a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.265s
success copy gatsby files - 0.510s
verbose Attaching functions to development server
success Compiling Gatsby Functions - 1.030s
success onPreBootstrap - 1.132s
verbose Creating 5 worker
verbose Transition to "initializingData"
success createSchemaCustomization - 0.034s
verbose Transition to "initializingData" > "sourcingNodes"
warn unable to find prism language 'zsh' for highlighting. applying generic code block
warn LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does
nothing in display mode [newLineInDisplayMode]
warn LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does
nothing in display mode [newLineInDisplayMode]
warn unable to find prism language 'jsxx' for highlighting. applying generic code block
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 0 changed pages
success Checking for changed pages - 0.018s
success source and transform nodes - 8.055s
verbose Transition to "initializingData" > "buildingSchema"
success building schema - 0.887s
verbose Transition to "initializingData" > "creatingPages"
success createPages - 0.215s
success createPagesStatefully - 0.420s
info Total nodes: 149, SitePage nodes: 39 (use --verbose for breakdown)
verbose Number of node types: 8. Nodes per type: Directory: 12, File: 20, ImageSharp: 9, Mdx:
10, Site: 1, SiteBuildMetadata: 1, SitePage: 39, SitePlugin: 57
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 39 changed pages
success Checking for changed pages - 0.006s
verbose Transition to "initializingData" > "writingOutRedirects"
success write out redirect data - 0.008s
verbose Transition to "initializingData" > "done"
verbose Transition to "runningPostBootstrap"
success Build manifest and related icons - 0.690s
success onPostBootstrap - 0.707s
info bootstrap finished - 50.682s
verbose Transition to "runningQueries"
success onPreExtractQueries - 0.008s
success extract queries from components - 6.416s
verbose Transition to "runningQueries" > "waitingPendingQueries"
verbose Transition to "runningQueries" > "writingRequires"
success write out requires - 0.157s
verbose Transition to "runningQueries" > "calculatingDirtyQueries"
verbose Transition to "runningQueries" > "runningStaticQueries"
success run static queries - 0.062s - 1/1 16.03/s
verbose Transition to "runningQueries" > "runningPageQueries"
warn LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does
nothing in display mode [newLineInDisplayMode]
warn LaTeX-incompatible input and strict mode is set to 'warn': In LaTeX, \\ or \newline does
nothing in display mode [newLineInDisplayMode]
[                            ]   1.722 s 0/3 0% run page queries
error Command failed with signal "SIGSEGV".

Environment

System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Languages:
    Python: 3.10.4 - /usr/bin/python
  Browsers:
    Firefox: 101.0
  npmPackages:
    gatsby: 4.15 => 4.15.2 
    gatsby-plugin-eslint: ^4.0.2 => 4.0.2 
    gatsby-plugin-exclude: ^1.0.2 => 1.0.2 
    gatsby-plugin-feed: ^4.15.1 => 4.15.1 
    gatsby-plugin-gatsby-cloud: ^4.15.0 => 4.15.0 
    gatsby-plugin-google-gtag: ^4.15.0 => 4.15.0 
    gatsby-plugin-image: ^2.15.1 => 2.15.1 
    gatsby-plugin-manifest: ^4.15.1 => 4.15.1 
    gatsby-plugin-mdx: ^3.15.1 => 3.15.1 
    gatsby-plugin-mdx-embed: ^1.0.0 => 1.0.0 
    gatsby-plugin-offline: ^5.15.1 => 5.15.1 
    gatsby-plugin-page-creator: ^4.15.1 => 4.15.1 
    gatsby-plugin-react-helmet: ^5.15.0 => 5.15.0 
    gatsby-plugin-sass: ^5.15.1 => 5.15.1 
    gatsby-plugin-sharp: ^4.15.1 => 4.15.1 
    gatsby-plugin-sitemap: ^5.15.1 => 5.15.1 
    gatsby-plugin-smoothscroll: ^1.2.0 => 1.2.0 
    gatsby-remark-autolink-headers: ^5.15.1 => 5.15.1 
    gatsby-remark-check-links: ^2.1.0 => 2.1.0 
    gatsby-remark-copy-linked-files: ^5.15.0 => 5.15.0 
    gatsby-remark-embed-snippet: ^7.15.0 => 7.15.0 
    gatsby-remark-graphviz: ^4.15.0 => 4.15.0 
    gatsby-remark-images: ^6.15.1 => 6.15.1 
    gatsby-remark-mermaid: ^2.1.0 => 2.1.0 
    gatsby-remark-prismjs: ^6.15.0 => 6.15.0 
    gatsby-remark-responsive-iframe: ^5.15.0 => 5.15.0 
    gatsby-remark-smartypants: ^5.15.0 => 5.15.0 
    gatsby-source-filesystem: ^4.15.0 => 4.15.0 
    gatsby-transformer-remark: ^5.15.1 => 5.15.1 
    gatsby-transformer-sharp: ^4.15.1 => 4.15.1

Config Flags

No response

kxxt commented 2 years ago

I tested v4.15.0-next.0 and it works. So this issue might be caused by lmdb v2.3.10 in https://github.com/gatsbyjs/gatsby/pull/35585.

LekoArts commented 2 years ago

Hi!

Please report this at https://github.com/kriszyp/lmdb-js/issues and be sure to also attach the detailed crash.log. This way @kriszyp will be able to better look into this. If you can reproduce it, that's even better!

Thanks!

kxxt commented 2 years ago

The corresponding upstream issue(https://github.com/kriszyp/lmdb-js/issues/175) has been fixed in lmdb v2.5.1