RainwayApp / node-clangffi

Generate Typescript FFI bindings for C/C++ libraries using libclang and ffi-napi.
MIT License
7 stars 1 forks source link

Crash while generating bindings for ObjectBox #59

Open thecodrr opened 2 years ago

thecodrr commented 2 years ago

Hi,

I am trying to generate bindings for ObjectBox but clangffi keeps crashing with the following error:

  clangffi {
  clangffi   "_": [],
  clangffi   "lib-path": "/usr/lib/x86_64-linux-gnu/libclang-14.so",
  clangffi   "libPath": "/usr/lib/x86_64-linux-gnu/libclang-14.so",
  clangffi   "i": "objectbox.h",
  clangffi   "input": "objectbox.h",
  clangffi   "o": "objectbox.ts",
  clangffi   "output": "objectbox.ts",
  clangffi   "default-symbols": false,
  clangffi   "defaultSymbols": false,
  clangffi   "L": "c",
  clangffi   "language": "c",
  clangffi   "I": [],
  clangffi   "include-directory": [],
  clangffi   "includeDirectory": [],
  clangffi   "D": [],
  clangffi   "define": [],
  clangffi   "R": [],
  clangffi   "hard-remap": [],
  clangffi   "remap": [],
  clangffi   "hardRemap": [],
  clangffi   "crlf": false,
  clangffi   "prettier": true,
  clangffi   "include": [],
  clangffi   "include-file": [],
  clangffi   "includeFile": [],
  clangffi   "exclude": [],
  clangffi   "clean-enum-constants": true,
  clangffi   "cleanEnumConstants": true,
  clangffi   "$0": "clangffi"
  clangffi } +0ms
  clangffi:tsgen open(objectbox.ts): begin +0ms
  clangffi:tsgen open(objectbox.ts): end +1ms
  clangffi:parser skip '__u_char' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +0ms
  clangffi:parser skip '__u_short' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +16ms
  clangffi:parser skip '__u_int' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +17ms
  clangffi:parser skip '__u_long' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +19ms
  clangffi:parser skip '__int8_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +14ms
  clangffi:parser skip '__uint8_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +16ms
  clangffi:parser skip '__int16_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +17ms
  clangffi:parser skip '__uint16_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +15ms
  clangffi:parser skip '__int32_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +16ms
  clangffi:parser skip '__uint32_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +15ms
  clangffi:parser skip '__int64_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +16ms
  clangffi:parser skip '__uint64_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +15ms
  clangffi:parser skip '__int_least8_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +19ms
  clangffi:parser skip '__uint_least8_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +18ms
  clangffi:parser skip '__int_least16_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +15ms
  clangffi:parser skip '__uint_least16_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +16ms
  clangffi:parser skip '__int_least32_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +14ms
  clangffi:parser skip '__uint_least32_t' from '/usr/include/x86_64-linux-gnu/bits/types.h'. +15ms

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0x7ffee494ace0
 1: 0xb76401  [node]
 2: 0x1c09824 V8_Fatal(char const*, ...) [node]
 3: 0xfcecd1 v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr<v8::internal::BackingStore>) [node]
 4: 0xd20518 v8::ArrayBuffer::GetBackingStore() [node]
 5: 0xabdc90 napi_get_typedarray_info [node]
 6: 0x7f0f95c053ac  [/home/thecodrr/.npm/_npx/0a8e200cae307ad8/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 7: 0x7f0f95c05b48  [/home/thecodrr/.npm/_npx/0a8e200cae307ad8/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 8: 0x7f0f95c07831  [/home/thecodrr/.npm/_npx/0a8e200cae307ad8/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 9: 0x7f0f95c0d4ab Napi::details::CallbackData<void (*)(Napi::CallbackInfo const&), void>::Wrapper(napi_env__*, napi_callback_info__*) [/home/thecodrr/.npm/_npx/0a8e200cae307ad8/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
10: 0xab45dd  [node]
11: 0xd5531e  [node]
12: 0xd5673f v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x15f2199  [node]
Trace/breakpoint trap (core dumped)

I am running the following command:

DEBUG=clangffi* npx clangffi --lib-path /usr/lib/x86_64-linux-gnu/libclang-13.so -i objectbox.h -o objectbox.ts

Node v16.15.1 libclang v13

Header file: https://raw.githubusercontent.com/objectbox/objectbox-c/main/include/objectbox.h