Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global object may cause double free or corruption #50

Open
demon90s opened this issue Sep 4, 2023 · 1 comment
Open

global object may cause double free or corruption #50

demon90s opened this issue Sep 4, 2023 · 1 comment

Comments

@demon90s
Copy link

demon90s commented Sep 4, 2023

If we add some global object like "std::vectorstd::string v = { "1", "2", "3" };" in our cpp file, which will be compiled later at runtime. Now we reload the project, everything is ok.

Then, our program exit normally(not by signal), it will be crashed with some message like:

*** Error in `./main': double free or corruption (fasttop): 0x00000000019aeac0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81329)[0x7ff37cb07329]
/root/jet-live_test/build/lib_reload1.so(_ZN9__gnu_cxx13new_allocatorISsE10deallocateEPSsm+0x20)[0xc269f0]
/root/jet-live_test/build/lib_reload1.so(_ZNSt16allocator_traitsISaISsEE10deallocateERS0_PSsm+0x2b)[0xc268db]
.....

@ddovod
Copy link
Owner

ddovod commented Jul 10, 2024

Sorry, somehow I missed your question, probably was too busy on my primary work.

It's important to note what compiler is used, I noticed that on some gcc versions there're weird issues happening here and there. I just checked this case on clang 18.1.8 on xubuntu 24.04, works fine

std::vector<std::string> arr = { "1", "2", "3" };

int main() {
    std::string msg;
    while (true) {
        for (const auto& el : arr) {
            msg += el;
        }
        std::cout << msg << std::endl;
    }
}

I'm getting "123" log messages, but when I change the arr values to 3 2 1 and reload the code, I get 321 messages and no crashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants