facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.03k stars 6.23k forks source link

RocksDB crashes when initializing after an update through VCPKG #10918

Closed rafalsk closed 9 months ago

rafalsk commented 1 year ago

Platform: Windows 11 Build Tools: Visual Studio 2022 + VCPKG (no modes default attempt to install rocksdb lib). Expected Behavior: the library loads Situation: a right-away crash, before control is passed over to main(). Cause: an attempt to dereference a NULLPTR during library loading stage.

We've been using RocksDB for years, building from source on Windows through Visual Studio and stuff.

Today, I felt lazy and thought to myself, hey, there's VCPKG right..haven't updated RocksDB for like a year or so..

After getting my VCPKG to work with Visual Studio 2022 which was sort of an unexpected pain in the ass, building RocksDB was a walk in the park (of course).

I was handed with debug and release builds almost right away. Great right?

So I deleted all the internal RocksDB-related headers, copied over the VCPKG-baked static lib and... crash. Tried both debug and release mode. Here's the call stack:

 Rocksdb::Comparator::timestamp_size() Line 110    C++
rocksdb::InternalKeyComparator::InternalKeyComparator(const rocksdb::Comparator * c, bool named) Line 242   C++
rocksdb::ImmutableCFOptions::ImmutableCFOptions(const rocksdb::ColumnFamilyOptions & cf_options) Line 835   C++
rocksdb::ImmutableCFOptions::ImmutableCFOptions() Line 829  C++
rocksdb::`dynamic initializer for 'dummy_cf_options''() Line 43 C++

It crashed at the library loading stage, control is not even passed to my main() yet.

right over here

 explicit InternalKeyComparator(const Comparator* c, bool named = true)
  : Comparator(c->timestamp_size()), user_comparator_(c) {
if (named) {
  name_ = "rocksdb.InternalKeyComparator:" +
          std::string(user_comparator_.Name());
}

}

above 'c' is nullptr.

Ideas?`

Update: In order to isolate the issue, I've created a fresh new C++ Hello World project and linked the produced static lib.

I get unresolved externals as follows: LNK2019 unresolved external symbol __imp_RpcStringFreeA referenced in function "bool __cdecl rocksdb::port::GenerateRfcUuid(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?GenerateRfcUuid@port@rocksdb@@YA_NPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ConsoleApplication1 C:\Users\Dell\source\repos\ConsoleApplication1\ConsoleApplication1\rocksdbd.lib(port_win.cc.obj) 1 Error LNK2019 unresolved external symbol __imp_UuidCreateSequential referenced in function "bool __cdecl rocksdb::port::GenerateRfcUuid(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?GenerateRfcUuid@port@rocksdb@@YA_NPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ConsoleApplication1 C:\Users\Dell\source\repos\ConsoleApplication1\ConsoleApplication1\rocksdbd.lib(port_win.cc.obj) 1 Error LNK2019 unresolved external symbol __imp_UuidToStringA referenced in function "bool __cdecl rocksdb::port::GenerateRfcUuid(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?GenerateRfcUuid@port@rocksdb@@YA_NPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ConsoleApplication1 C:\Users\Dell\source\repos\ConsoleApplication1\ConsoleApplication1\rocksdbd.lib(port_win.cc.obj) 1 Error LNK2019 unresolved external symbol __imp_PathIsDirectoryA referenced in function "public: virtual class rocksdb::IOStatus __cdecl rocksdb::port::WinFileSystem::IsDirectory(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct rocksdb::IOOptions const &,bool *,struct rocksdb::IODebugContext *)" (?IsDirectory@WinFileSystem@port@rocksdb@@UEAA?AVIOStatus@3@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBUIOOptions@3@PEA_NPEAUIODebugContext@3@@Z) ConsoleApplication1 C:\Users\Dell\source\repos\ConsoleApplication1\ConsoleApplication1\rocksdbd.lib(env_win.cc.obj) 1 Error LNK2019 unresolved external symbol __imp_PathIsRelativeA referenced in function "public: static unsigned __int64 __cdecl rocksdb::port::WinFileSystem::GetSectorSize(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?GetSectorSize@WinFileSystem@port@rocksdb@@SA_KAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ConsoleApplication1 C:\Users\Dell\source\repos\ConsoleApplication1\ConsoleApplication1\rocksdbd.lib(env_win.cc.obj) 1

adamretter commented 1 year ago

@rafalsk the VCPKG is presumably provided by a third-party? We need to rule that out as that is not something we support directly. So... Do you see the same problems if you build your own lib from source?

adamretter commented 9 months ago

Closing due to a lack of response.