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

Crashes/segfaults with GCC 8.1 #23

Open
jtebert opened this issue Jan 24, 2019 · 3 comments
Open

Crashes/segfaults with GCC 8.1 #23

jtebert opened this issue Jan 24, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@jtebert
Copy link
Owner

jtebert commented Jan 24, 2019

Per @bcornille, fails with gcc 8.1.0 on Ubuntu 16.04

@jtebert jtebert added the bug Something isn't working label Jan 24, 2019
@r-barnes
Copy link
Collaborator

I can reproduce this with g++-8 (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0

Using the address sanitizer reveals that the bug arises at Line 30 of Logger.cpp:

m_trial_group_name = "trial_" + std::to_string(trial_num);
WARNING: Overwrote trial data
=================================================================
==14158==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x7fff65934f20 in thread T0
    #0 0x7faf4e4aa640 in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xf0640)
    #1 0x56025309e3b6 in __gnu_cxx::new_allocator<char>::deallocate(char*, unsigned long) /usr/include/c++/8/ext/new_allocator.h:125
    #2 0x56025309e3b6 in std::allocator_traits<std::allocator<char> >::deallocate(std::allocator<char>&, char*, unsigned long) /usr/include/c++/8/bits/alloc_traits.h:462
    #3 0x56025309e3b6 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_destroy(unsigned long) /usr/include/c++/8/bits/basic_string.h:226
    #4 0x56025309e3b6 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() /usr/include/c++/8/bits/basic_string.h:221
    #5 0x56025309e3b6 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() /usr/include/c++/8/bits/basic_string.h:657
    #6 0x56025309e3b6 in KiloSim::Logger::set_trial(unsigned int) src/Logger.cpp:30
    #7 0x5602530fc839 in KiloSim::Logger::Logger(KiloSim::World*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, bool) src/Logger.cpp:18
    #8 0x5602530a31e7 in main src/test.cpp:68
    #9 0x7faf4c22cb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #10 0x5602530a5609 in _start (/home/rick/projects/contributing/kilosim/bin/kilosim+0x15609)

Address 0x7fff65934f20 is located in stack of thread T0
SUMMARY: AddressSanitizer: bad-free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xf0640) in operator delete(void*)
==14158==ABORTING
Aborted (core dumped)

I can't see any reason why this would be a problem, so I'm guessing it's a compiler regression and the best way to fix it is to try to build a small reproducer and forward it to the GCC folks.

@r-barnes
Copy link
Collaborator

I've just tried with g++-8 (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0 and there is no crash. Either it was a compiler bug in earlier versions of the code (I believe this), or it was a bug that got fixed amid other changes (I think this is less likely). We can probably declare victory here, or we could be more thorough and test earlier GCC8 series compilers to see if we can rove this more rigorously.

@r-barnes
Copy link
Collaborator

One way to do this would be godbolt plus this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants