Skip to content

SIGABRT (Invalid Free) in node.napi.node during Next.js build on macOS ARM64 (Node v24) #348

@jabakochashvilisunrun

Description

@jabakochashvilisunrun

Hello! I'm experiencing a hard crash (SIGABRT) when trying to build a Next.js app that uses lmdb. The crash occurs during the build process.

This repository provides a minimal reproduction with the latest version of lmdb and next.

Environment:

  • Node.js: v24.13.0
  • macOS: 26.2
  • Chip: Apple Silicon M4
  • Architecture: ARM-64

Steps to Reproduce:

  1. Clone the reproduction repository:
git clone https://github.com/jabakochashvilisunrun/lmdb-crash-repro.git
cd lmdb-crash-repro
  1. Install dependencies:
npm install
  1. Build the app:
npm run build
  1. The build fails with a SIGABRT signal after building around 120 pages.

Observed Output:

⨯ Next.js build worker exited with code: null and signal: SIGABRT

Crash Report Details:
The native crash log indicates a memory management issue (___BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATED).

The stack trace points to node.napi.node attempting to free a std::unordered_map during the EnvWrap::closeEnv phase.
Relevant Stack Trace:

Exception Type:        EXC_CRASH (SIGABRT)
Termination Reason:    Namespace SIGNAL, Code 6, Abort trap: 6
Terminating Process:   node [66417]

Application Specific Information:
abort() called

Thread 0 Crashed:: MainThread Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          ... __pthread_kill + 8
1   libsystem_pthread.dylib         ... pthread_kill + 296
2   libsystem_c.dylib               ... abort + 124
3   libsystem_malloc.dylib          ... malloc_vreport + 892
4   libsystem_malloc.dylib          ... malloc_report + 64
5   libsystem_malloc.dylib          ... ___BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATED + 76
6   node.napi.node                  ... void std::__1::__libcpp_operator_delete[abi:un170006]<void*>(void*) + 24
...
15  node.napi.node                  ... std::__1::__hash_table<...>::~__hash_table() + 56
...
19  node.napi.node                  ... ExtendedEnv::~ExtendedEnv() + 64
20  node.napi.node                  ... ExtendedEnv::~ExtendedEnv() + 28
21  node.napi.node                  ... EnvWrap::closeEnv(bool) + 1140

Any suggestions or potential fixes for this would be greatly appreciated. Thanks for your time and for maintaining this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions