Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.39k stars 1.91k forks source link

In MMKV.cpp, for the variable MMKVPath_t g_rootDir, using a pointer might be a better choice. #1363

Closed waitianlou closed 3 months ago

waitianlou commented 3 months ago

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

Objective-C

The version of MMKV

1.3.5

The platform of MMKV

iOS

The installation of MMKV

Cocoapods

What's the issue?

Using MMKV before the main, which means call initializeMMKV before main (such as in +load or other) will cause global class object MMKVPath_t to be overwritten as nil by __cxx_global_var_init after manual initialization.

What's the log of MMKV when that happened?

log:fail to open xxxxx (in MemoryFile.cpp) because g_rootDir is nil set by __cxx_global_var_init

lingol commented 3 months ago

Never use MMKV before the main(), period.

waitianlou commented 3 months ago

Never use MMKV before the main(), period.

Are there any known issues here, or has MMKV not been fully tested in this scenario?

lingol commented 3 months ago

You can't use MMKV before properly initializing it, and you can't properly initialize it before main().