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

cmerge: segfault #3220

Closed
mpranj opened this issue Nov 15, 2019 · 7 comments
Closed

cmerge: segfault #3220

mpranj opened this issue Nov 15, 2019 · 7 comments
Assignees
Labels
Milestone

Comments

@mpranj
Copy link
Member

mpranj commented Nov 15, 2019

Steps to Reproduce the Problem

Configure and make libelektra.

make run all

Expected Result

All tests succeed.

Actual Result

The following tests FAILED:
	210 - testshell_markdown_cmerge (Failed)
	225 - test_cmerge (SEGFAULT)
 valgrind ./bin/test_cmerge
==200629== Memcheck, a memory error detector
==200629== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==200629== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==200629== Command: ./bin/test_cmerge
==200629== 
CMERGE       TESTS
==================

Executing testValuesWithGivenLength with size 59
==200629== Jump to the invalid address stated on the next line
==200629==    at 0x0: ???
==200629==    by 0xF: ???
==200629==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==200629== 
==200629== 
==200629== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==200629==  Bad permissions for mapped region at address 0x0
==200629==    at 0x0: ???
==200629==    by 0xF: ???
==200629== 
==200629== HEAP SUMMARY:
==200629==     in use at exit: 4,388 bytes in 64 blocks
==200629==   total heap usage: 169 allocs, 105 frees, 81,447 bytes allocated
==200629== 
==200629== LEAK SUMMARY:
==200629==    definitely lost: 0 bytes in 0 blocks
==200629==    indirectly lost: 0 bytes in 0 blocks
==200629==      possibly lost: 0 bytes in 0 blocks
==200629==    still reachable: 4,388 bytes in 64 blocks
==200629==         suppressed: 0 bytes in 0 blocks
==200629== Rerun with --leak-check=full to see details of leaked memory
==200629== 
==200629== For lists of detected and suppressed errors, rerun with: -s
==200629== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
[1]    200629 segmentation fault (core dumped)  valgrind ./bin/test_cmerge

System Information

  • Elektra Version: master
  • Fedora 31

Further Log Files and Output

cmerge.txt

@mpranj
Copy link
Member Author

mpranj commented Nov 15, 2019

I have libgit2 0.28.3 on linux and this does not work. Removing the CMERGE_ON_LINUX check in the code fixes the segfault.

#ifndef CMERGE_ON_LINUX

@mpranj mpranj added the bug label Nov 15, 2019
@markus2330 markus2330 added this to the 0.9.1 milestone Nov 15, 2019
@markus2330
Copy link
Contributor

markus2330 commented Nov 15, 2019

Thank you for reporting this problem!

We should definitely fix this before 0.9.1. Maybe by simply disabling libgit2 in this case.

@mpranj can you also post the gdb output, the valgrind output is not so helpful.

@dominicjaeger
Copy link
Contributor

I bet it's about LibGit. The library should be initialized with git_libgit2_init() according to their documentation.

When not initializing LibGit on all the Linux on the build server we get no memory leaks. If we initialize, we do. However, if we don't initialize for the FreeBSD builds, we get segfaults. This is the reason why those strange ifdefs exist. I also made my first Stackoverflow post about this.

Hopefully #3221 fixes this.

@mpranj
Copy link
Member Author

mpranj commented Nov 16, 2019

Gdb output is also not very helpful. I'm not sure why, I have the debug symbols of the libraries and it's a Debug build of elektra.

GNU gdb (GDB) Fedora 8.3.50.20190824-24.fc31
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/test_cmerge...
(gdb) r
Starting program: /home/mpranj/workspace/libelektra/build/bin/test_cmerge 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
CMERGE       TESTS
==================

Executing testValuesWithGivenLength with size 59

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) q

I've verified that the #ifndef CMERGE_ON_LINUX is the root cause on my system, but I did not have time to make a portable patch for it.

@mpranj
Copy link
Member Author

mpranj commented Nov 16, 2019

@Chemin1 thank you for working on it!

@mpranj
Copy link
Member Author

mpranj commented Nov 16, 2019

@Chemin1 thank you for fixing it so quickly. I can confirm that it works for me now.

@mpranj mpranj closed this as completed Nov 16, 2019
@dominicjaeger
Copy link
Contributor

Thank you for testing it, @mpranj !

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

No branches or pull requests

3 participants