RocksDB public-header asserts are compiled live into release builds

Open
#1,114 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, node.js
Domain
backend, devtools

Research direction

Read the addon's Release configuration and the #1113 fix in src/binding, then inspect the assert usage under deps/rocksdb/include/rocksdb. Compare the two proposed options against the build behavior and the stated ABI concern; done means deciding and documenting whether release builds keep these header asserts live or disable them under the specified condition.

Written by the indexing model from the issue text.

Description

bug

Problem

Found while fixing #1113 (Release builds abort the process when an internal native assert fails). The addon's Release configuration defines no NDEBUG, so the assert() calls inside RocksDB's public headers are live too: every inline header function our translation units instantiate carries its assert into the published .node. The fix for #1113 only covers asserts we own in src/binding; it cannot reach these.

Evidence from a macOS arm64 release build of main (043141a1), via strings/nm on build/Release/rocksdb-js.node:

  • nm -u lists __assert_rtn (the libc assert failure handler), still imported after #1113's fix.
  • Assert strings from RocksDB headers are present, for example slice.h / data_ != nullptr && b.data_ != nullptr, db.h / value != nullptr, write_buffer_manager.h / new_size > 0, and compaction_filter.h.

29 headers under deps/rocksdb/include/rocksdb use assert. None of them use NDEBUG to change a struct layout, so defining it would not create an ABI mismatch with the prebuilt librocksdb (which is itself built with NDEBUG).

Impact

Each of these guards misuse of the RocksDB API by our code, so a violation is a bug of ours, not of a caller. No trigger is known: the one I checked (WriteBufferManager::SetBufferSize(0)) is already guarded in db_settings.cpp. If one fires, the host process gets SIGABRT with no JS error, the same failure class as #1113.

Options

  1. Define NDEBUG in the addon's Release configuration only when ROCKSDB_JS_FATAL_ASSERTS is unset (so CI builds keep RocksDB's header asserts live and the published prebuilds match how RocksDB compiles its own library). Trade-off: in the published build, a misuse would then continue into whatever the assert was guarding, which for Slice accessors is undefined behaviour rather than an abort.
  2. Leave them live and document it: an abort is arguably safer than undefined behaviour at those particular sites.

🤖 Generated by Claude Code (Claude Opus 5.5); posted via @cb1kenobi.

Dominant language
C++
Stars
24
Forks
3
Avg merge
1d 17h
Merged PRs (30d)
94

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HarperFast/rocksdb-js

All issues in HarperFast/rocksdb-js

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.