#1833 segmentation fault in cmocka unit tests with raised optization level
Closed: Fixed None Opened 6 years ago by okos.

the nss-srv-tests are failing when compiled with optimization turned on

dctx pointer gets nullified here

src/responder/nss/nsssrv_cmd.c:593

req = sss_dp_get_account_send(cctx, cctx->rctx, dctx->domain, true,
                              req_type, opt_name, opt_id, NULL);




(gdb) bt
#0  check_cache (dctx=0x0, dctx@entry=0xf556b0, nctx=nctx@entry=0xf509d0, res=<optimized out>, 
    req_type=req_type@entry=1, opt_name=opt_name@entry=0xf51970 "testuser_search", opt_id=opt_id@entry=0, 
    callback=callback@entry=0x41e2b0 <nss_cmd_getpwnam_dp_callback>, pvt=pvt@entry=0xf556b0)
    at src/responder/nss/nsssrv_cmd.c:610
#1  0x000000000041dbb4 in nss_cmd_getpwnam_search (dctx=dctx@entry=0xf556b0) at src/responder/nss/nsssrv_cmd.c:805
#2  0x000000000041e8af in nss_cmd_getpwnam_cb (req=<optimized out>) at src/responder/nss/nsssrv_cmd.c:1015
#3  0x00000031a0e048e2 in tevent_common_loop_immediate (ev=ev@entry=0xf50630) at ../tevent_immediate.c:135
#4  0x00000031a0e073e0 in std_event_loop_once (ev=0xf50630, location=<optimized out>) at ../tevent_standard.c:556
#5  0x00000031a0e04060 in _tevent_loop_once (ev=0xf50630, location=location@entry=
    0x42deec "src/tests/common_tev.c:57") at ../tevent.c:507
#6  0x000000000040410e in test_ev_loop (tctx=0xf54990) at src/tests/common_tev.c:57
#7  0x000000000040f15b in test_nss_getpwnam_search (state=<optimized out>) at src/tests/cmocka/test_nss_srv.c:323
#8  0x00007f5146f3f82a in _run_test (function_name=0x430210 "test_nss_getpwnam_search", Function=
    0x40f080 <test_nss_getpwnam_search>, state=0xf53ce0, state@entry=0xf4a078, function_type=
    UNIT_TEST_FUNCTION_TYPE_TEST, heap_check_point=<optimized out>) at /usr/src/debug/cmocka-0.2.0/src/cmocka.c:1673
#9  0x00007f5146f3fade in _run_tests (tests=tests@entry=0x7fff6a5a4110, number_of_tests=number_of_tests@entry=12)
    at /usr/src/debug/cmocka-0.2.0/src/cmocka.c:1785
#10 0x0000000000403d0c in main (argc=1, argv=<optimized out>) at src/tests/cmocka/test_nss_srv.c:507

to be specific, it fails for optimization levels lower then -O3

Fields changed

cc: => sgallagh

after more investigation, the failure occurs only on 64bit systems and with following optimization levels:

-O -O1 -O2 -Os

with -O0 -O3 and -Ofast the tests won't crash

Running with stack protector:

*** stack smashing detected ***: /home/pbrezina/git/sssd/.libs/lt-nss-srv-tests terminated
======= Backtrace: =========
/lib64/libc.so.6(__fortify_fail+0x37)[0x7ff8de308697]
/lib64/libc.so.6(__fortify_fail+0x0)[0x7ff8de308660]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x404174]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x41f27f]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x40fb49]
/lib64/libcmocka.so.0(_run_test+0x11a)[0x7ff8e1f1282a]
/lib64/libcmocka.so.0(_run_tests+0x10e)[0x7ff8e1f12ade]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x403d26]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff8de21fa05]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x403d91]




#0  0x00007fe7becc3ba5 in raise () from /lib64/libc.so.6
#1  0x00007fe7becc5358 in abort () from /lib64/libc.so.6
#2  0x00007fe7bed0359b in __libc_message () from /lib64/libc.so.6
#3  0x00007fe7bed98697 in __fortify_fail () from /lib64/libc.so.6
#4  0x00007fe7bed98660 in __stack_chk_fail () from /lib64/libc.so.6
#5  0x0000000000404184 in test_request_send (mem_ctx=<optimized out>, ev=0x1980690, err=0) at src/tests/common_tev.c:45
#6  0x000000000041f28f in nss_cmd_getpwnam (cctx=0x19869e0) at src/responder/nss/nsssrv_cmd.c:949
#7  0x000000000040fb59 in test_nss_getpwnam (state=<optimized out>) at src/tests/cmocka/test_nss_srv.c:223
#8  0x00007fe7c29a282a in _run_test () from /lib64/libcmocka.so.0
#9  0x00007fe7c29a2ade in _run_tests () from /lib64/libcmocka.so.0
#10 0x0000000000403d36 in main (argc=1, argv=<optimized out>) at src/tests/cmocka/test_nss_srv.c:507

_comment0: Running with stack protector:

{{{
stack smashing detected : /home/pbrezina/git/sssd/.libs/lt-nss-srv-tests terminated
======= Backtrace: =========
/lib64/libc.so.6(__fortify_fail+0x37)[0x7ff8de308697]
/lib64/libc.so.6(__fortify_fail+0x0)[0x7ff8de308660]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x404174]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x41f27f]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x40fb49]
/lib64/libcmocka.so.0(_run_test+0x11a)[0x7ff8e1f1282a]
/lib64/libcmocka.so.0(_run_tests+0x10e)[0x7ff8e1f12ade]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x403d26]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff8de21fa05]
/home/pbrezina/git/sssd/.libs/lt-nss-srv-tests[0x403d91]
}}}
=> 1363097789325159

Fields changed

owner: somebody => pbrezina
status: new => assigned

Fields changed

patch: 0 => 1

master: f51639d

resolution: => fixed
status: assigned => closed

Fields changed

milestone: NEEDS_TRIAGE => SSSD 1.10 beta
rhbz: => 0

Metadata Update from @okos:
- Issue assigned to pbrezina
- Issue set to the milestone: SSSD 1.10 beta

2 years ago

Login to comment on this ticket.

Metadata