Monday, 6 September 2021

Static variable getting pre initialized with random values

Can someone please explain why a member variable (m_DBFileName) of static variable (g_JournalDB) getting initialized with a random value? I expect it to be populated with '\0's.

enter image description here

More info: g_JournalDB is part of a dynamic library loaded on app startup via

public class MyApplication extends Application {
    static {
        System.loadLibrary("mylibrary");
        ...
        System.loadLibrary("mylibraryN");
    }
    @override
    public void onCreate() {...}
    ...
}

The screenshot above was taken from a breakpoint in onCreate() of MyApplication where g_JournalDB gets created. I can provide more info if needed.

EDIT: Is it possible that, since I am loading multiple .so files, one ore more .so files have overlapping memory map?



from Static variable getting pre initialized with random values

No comments:

Post a Comment