kriszyp / lmdb-js

Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Other
484 stars 39 forks source link

1.6.0 breaks on Alpine Linux (musl): `backtrace: symbol not found` #72

Closed michael42 closed 2 years ago

michael42 commented 2 years ago

Hi there,

I tried upgrading my transitive dependencies today and ran into a problem. lmdb-store did no longer install correctly on Alpine Linux 3.14, which I could fix by installing libexecinfo-dev.

But even now it doesn't run, failing with backtrace: symbol not found. As far as I researched, that's because backtrace is GNU-only function no available on musl other C standard libraries.

Reproduction:

$ docker run -it --rm alpine
$ apk add nodejs npm alpine-sdk python3 libexecinfo-dev
$ mkdir /test && cd /test && npm init -y && npm install lmdb-store@1.6.0
$ node -e 'require("lmdb-store")'
internal/modules/cjs/loader.js:1144
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Error relocating /test/node_modules/lmdb-store/build/Release/lmdb-store.node: backtrace: symbol not found
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at load (/test/node_modules/node-gyp-build/index.js:21:10)
    at Object.<anonymous> (/test/node_modules/lmdb-store/index.js:7:49)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)

Running ldd on the compiled lmdb-store.node prints 112 symbol not found errors on musl, but apparently it worked enough for my use-case previously on 1.5.5.

kriszyp commented 2 years ago

Added a commit to only compile backtraces GNU C. Out of curiosity what other symbols are not found? Should I fix them as well?

michael42 commented 2 years ago

Awesome, thanks for the fast reaction. The full output of ldd on Alpine is this (which I don't really understand, is that the C++ compiler's name mangling?):

# ldd node_modules/lmdb-store/build/Release/lmdb-store.node 
        /lib/ld-musl-x86_64.so.1 (0x7f5c11618000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f5c1141c000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f5c11618000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f5c11402000)
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v814ObjectTemplate21SetInternalFieldCountEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v88internal35IsolateFromNeverReadOnlySpaceObjectEm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: backtrace: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8ToStringENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node19GetCurrentEventLoopEPN2v87IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_cond_init: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8IsSymbolEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v88External3NewEPNS_7IsolateEPv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value9IsBooleanEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v88External5ValueEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer11HasInstanceEN2v85LocalINS1_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String18NewExternalOneByteEPNS_7IsolateEPNS0_29ExternalOneByteStringResourceE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v814ScriptCompiler10CachedDataD1Ev: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86String6LengthEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8ToNumberENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer6LengthEN2v85LocalINS1_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v811HandleScopeC1EPNS_7IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v87Boolean5ValueEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_close: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v820EscapableHandleScopeC1EPNS_7IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Symbol3ForEPNS_7IsolateENS_5LocalINS_6StringEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_cond_wait: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v814ScriptCompiler7CompileENS_5LocalINS_7ContextEEEPNS0_6SourceENS0_14CompileOptionsENS0_13NoCacheReasonE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v811HandleScopeD1Ev: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value12BooleanValueEPNS_7IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object3SetENS_5LocalINS_7ContextEEEjNS1_INS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V818GlobalizeReferenceEPNS_8internal7IsolateEPm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value9ToBooleanEPNS_7IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value10IsFunctionEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String9Utf8ValueC1EPNS_7IsolateENS_5LocalINS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V89ClearWeakEPm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Array6LengthEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Isolate10GetCurrentEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v816FunctionTemplate12SetClassNameENS_5LocalINS_6StringEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeEPKNS_9CFunctionE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer4DataEN2v85LocalINS1_6ObjectEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Number3NewEPNS_7IsolateEd: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v816FunctionTemplate17PrototypeTemplateEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86BigInt10Int64ValueEPb: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node25AddEnvironmentCleanupHookEPN2v87IsolateEPFvPvES3_: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object20SlowGetInternalFieldEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Integer15NewFromUnsignedEPNS_7IsolateEj: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value7ToInt32ENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86String9IsOneByteEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object3SetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEES5_: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String14NewFromOneByteEPNS_7IsolateEPKhNS_13NewStringTypeEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86String5WriteEPNS_7IsolateEPtiii: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v89Exception5ErrorENS_5LocalINS_6StringEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer3NewEPN2v87IsolateEm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node12MakeCallbackEPN2v87IsolateENS0_5LocalINS0_6ObjectEEENS3_INS0_8FunctionEEEiPNS3_INS0_5ValueEEENS_13async_contextE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_cond_signal: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86Symbol11DescriptionEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8IsBigIntEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String14NewFromTwoByteEPNS_7IsolateEPKtNS_13NewStringTypeEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_queue_work: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86Number5ValueEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v88Function11NewInstanceENS_5LocalINS_7ContextEEEiPNS1_INS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value6IsTrueEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer4CopyEPN2v87IsolateEPKcm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node16EmitAsyncDestroyEPN2v87IsolateENS_13async_contextE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_mutex_lock: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Isolate14ThrowExceptionENS_5LocalINS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Isolate17GetCurrentContextEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node13EmitAsyncInitEPN2v87IsolateENS0_5LocalINS0_6ObjectEEENS3_INS0_6StringEEEd: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object16SetInternalFieldEiNS_5LocalINS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer3NewEPN2v87IsolateEPcmPFvS4_PvES5_: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v815ArrayBufferView10ByteLengthEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8IsObjectEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: backtrace_symbols_fd: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_mutex_init: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String11NewFromUtf8EPNS_7IsolateEPKcNS_13NewStringTypeEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_async_init: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Script3RunENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V817FromJustIsNothingEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8IsUint32Ev: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v814ObjectTemplate3NewEPNS_7IsolateENS_5LocalINS_16FunctionTemplateEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v811HandleScope12CreateHandleEPNS_8internal7IsolateEm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value11Uint32ValueENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V812ToLocalEmptyEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object3NewEPNS_7IsolateE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_cond_destroy: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v816FunctionTemplate16InstanceTemplateEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v88Function4CallENS_5LocalINS_7ContextEEENS1_INS_5ValueEEEiPS5_: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object18InternalFieldCountEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v86String9WriteUtf8EPNS_7IsolateEPciPii: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8IsNumberEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value8ToObjectENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_async_send: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Context6GlobalEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v815ArrayBufferView12CopyContentsEPvm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v816FunctionTemplate11GetFunctionENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V813DisposeGlobalEPm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value12IntegerValueENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v811HandleScopeD2Ev: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value7IsArrayEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_mutex_unlock: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v82V88MakeWeakEPmPvPFvRKNS_16WeakCallbackInfoIvEEENS_16WeakCallbackTypeE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object32SetAlignedPointerInInternalFieldEiPv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object3GetENS_5LocalINS_7ContextEEENS1_INS_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value9ToIntegerENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: uv_mutex_destroy: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v811ArrayBuffer6DetachEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN4node6Buffer4DataEN2v85LocalINS1_5ValueEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZNK2v85Value17IsArrayBufferViewEv: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v85Array3NewEPNS_7IsolateEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v87Integer3NewEPNS_7IsolateEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v814ObjectTemplate11NewInstanceENS_5LocalINS_7ContextEEE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object3GetENS_5LocalINS_7ContextEEEj: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86Object38SlowGetAlignedPointerFromInternalFieldEi: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v88Template3SetENS_5LocalINS_4NameEEENS1_INS_4DataEEENS_17PropertyAttributeE: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v820EscapableHandleScope6EscapeEPm: symbol not found
Error relocating node_modules/lmdb-store/build/Release/lmdb-store.node: _ZN2v86String9Utf8ValueD1Ev: symbol not found

While checking this, I also did a quick check if the __GNUC__ change fixes the issue, but apparently backtrace is still required. I just tried using #if defined(__GLIBC__) && !defined(__UCLIBC__) as suggested in this stackoverflow answer and that seems to work.

kriszyp commented 2 years ago

Implemented your suggestion in v1.6.2.

michael42 commented 2 years ago

I'm afraid signalHandler is missing now, because setupExportMisc still uses __GNUC__:

Error: Error relocating /test/node_modules/lmdb-store/build/Release/lmdb-store.node: _Z13signalHandleri: symbol not found
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at load (/test/node_modules/node-gyp-build/index.js:21:10)

Third time's the charm probably. 🙂

kriszyp commented 2 years ago

Ugh, sorry 🤦‍♂️ . Will get that fix published soon.

michael42 commented 2 years ago

1.6.3 works fine for me, thanks.