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

make check segmentation fault in test-api on macOS Sierra #461

Closed
yan12125 opened this issue May 3, 2017 · 5 comments
Closed

make check segmentation fault in test-api on macOS Sierra #461

yan12125 opened this issue May 3, 2017 · 5 comments

Comments

@yan12125
Copy link

yan12125 commented May 3, 2017

As title, test-api crashes on Sierra:

../build/ac-aux/test-driver: line 107: 66360 Segmentation fault: 11  "$@" > $log_file 2>&1
FAIL: test-api

System information:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.12.4
BuildVersion:	16E195

Here's the lldb log:

$ lldb ./tests/.libs/test-api
(lldb) target create "./tests/.libs/test-api"
Current executable set to './tests/.libs/test-api' (x86_64).
(lldb) env DYLD_LIBRARY_PATH=./src/.libs
(lldb) env abs_top_srcdir=/Users/yen/tmp/augeas
(lldb) run
Process 66644 launched: './tests/.libs/test-api' (x86_64)
Process 66644 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7067a00)
    frame #0: 0x00007fffc8263297 libsystem_platform.dylib`_platform_strcmp + 23
libsystem_platform.dylib`_platform_strcmp:
->  0x7fffc8263297 <+23>: movzbq (%rsi), %r8
    0x7fffc826329b <+27>: incq   %rdi
    0x7fffc826329e <+30>: incq   %rsi
    0x7fffc82632a1 <+33>: subq   %r8, %rax
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7067a00)
  * frame #0: 0x00007fffc8263297 libsystem_platform.dylib`_platform_strcmp + 23
    frame #1: 0x0000000100003660 test-api`CuAssertStrEquals_LineMsg(tc=0x00000001002020a0, file=<unavailable>, line=<unavailable>, message="span_test 1 filename\n", expected="hosts", actual="") at cutest.c:131 [opt]
    frame #2: 0x00000001000020b6 test-api`testNodeInfo(tc=0x00000001002020a0) at test-api.c:388 [opt]
    frame #3: 0x00000001000034d3 test-api`CuTestRun(tc=0x00000001002020a0, setup=0x0000000000000000, teardown=0x0000000000000000) at cutest.c:87 [opt]
    frame #4: 0x0000000100003c1b test-api`CuSuiteRun(testSuite=0x0000000100801000) at cutest.c:243 [opt]
    frame #5: 0x0000000100000d30 test-api`main at test-api.c:772 [opt]
    frame #6: 0x00007fffc8054235 libdyld.dylib`start + 1
(lldb) up
test-api was compiled with optimization - stepping may behave oddly; variables may not be available.
frame #1: 0x0000000100003660 test-api`CuAssertStrEquals_LineMsg(tc=0x00000001002020a0, file=<unavailable>, line=<unavailable>, message="span_test 1 filename\n", expected="hosts", actual="") at cutest.c:131 [opt]
   128
   129 	    if ((expected == NULL && actual == NULL) ||
   130 	        (expected != NULL && actual != NULL &&
-> 131 	         strcmp(expected, actual) == 0))
   132 	        {
   133 	            return;
   134 	        }
(lldb) p actual
(const char *) $0 = 0x0000000007067a00 ""
(lldb) p *actual
error: Couldn't apply expression side effects : Couldn't dematerialize a result variable: couldn't read its memory
@lutter
Copy link
Member

lutter commented May 4, 2017

Thanks for the bug report. What happens there is a little strange, as the actual value (in testNodeInfo/test-api.c:388) is the result of calling basename; unfortunately, I can't reproduce the problem on my machine (Fedora 25) and I don't have macOS Sierra anywhere.

If you could, it would be great to look at the invocation of basename at test-api.c:383 and make sure that (a) the string filename_ac is valid and (b) what basename returns for that. The difference might be that on Linux we are getting the GNU version of basename and on OSX we are getting the POSIX version and there's some subtle difference.

@yan12125
Copy link
Author

yan12125 commented May 4, 2017

Aha, I played with test-api.c and found an absolutely simple fix:

diff --git a/tests/test-api.c b/tests/test-api.c
index 8264887b..28be3022 100644
--- a/tests/test-api.c
+++ b/tests/test-api.c
@@ -28,6 +28,7 @@
 #include "internal.h"

 #include <unistd.h>
+#include <libgen.h>

 #include <libxml/tree.h>

Seems either Clang or the dynamic linker can't handle implicit C function declarations well.

@lutter
Copy link
Member

lutter commented May 5, 2017

Nice find, thanks ! Committed a fix as 51b6ec6b

@lutter lutter closed this as completed May 5, 2017
lutter added a commit that referenced this issue Jun 11, 2017
Missing that include leads to segfaults on OS X Sierra.

Thanks to yan12125 for the fix

Fixes #461
@lutter
Copy link
Member

lutter commented Jun 11, 2017

Just realized I never pushed that; pushed it now as e57457f

@yan12125
Copy link
Author

Aha, I haven't had to to really test it either :) With the latest git-master all tests pass!

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