Project

General

Profile

Actions

Development tools

C tools

  • Lindent (from kernel source), reformat C code to the Linux kernel (and osmocom) coding standards
  • cflow to generate flow-graphs from source code

Patches

  • git format-patch -1, generate a patch
  • checkpatch.pl, check patches for common errors (Ignore x-signed-off-by)
  • make distcheck catches quite a few errors, run it before sending patches.
  • git send-email -1 Send a patch to the mailing list (after configuration)

Testing

  • make check: run it and don't introduce regressions
  • make distcheck: run it to make sure that make dist contains everything needed and you didn't forget to add any files to Makefile.am
  • Our extensive Titan_TTCN3_Testsuites

AddressSanitizer

All Osmocom CNI projects support building iwth ./configure --enable-sanitize, which enables support for AddressSanitizer

This is extremely useful in finding a variety of problems, such as use-after-free.

meaniungful backtraces

Often the backtraces you get from asan are too short to figure out where an allocation/free has happened, like:

0x612000000eb8 is located 248 bytes inside of 296-byte region [0x612000000dc0,0x612000000ee8)
freed by thread T0 here:
    #0 0x7f42477d9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
    #1 0x7f4246b2678a in _tc_free_internal ../../talloc.c:1221

previously allocated by thread T0 here:
    #0 0x7f42477d9e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f4246b28ecb in __talloc_with_prefix ../../talloc.c:782

In this case, it is recommended to run with the environment variable ASAN_OPTIONS="fast_unwind_on_malloc=0", which will produce a much more meaningful backtrace. The same bug as the above example now looks like this:

0x612000000eb8 is located 248 bytes inside of 296-byte region [0x612000000dc0,0x612000000ee8)
freed by thread T0 here:
    #0 0x7f5c3e64bb6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
    #1 0x7f5c3d99878a in _tc_free_internal ../../talloc.c:1221
    #2 0x7f5c3daa648e in fsm_free_or_steal /space/home/laforge/projects/git/libosmocore/src/fsm.c:116
    #3 0x7f5c3daa648e in osmo_fsm_inst_free /space/home/laforge/projects/git/libosmocore/src/fsm.c:574
    #4 0x7f5c3daab8ef in _osmo_fsm_inst_term /space/home/laforge/projects/git/libosmocore/src/fsm.c:959
    #5 0x7f5c3daadb09 in fsm_tmr_cb /space/home/laforge/projects/git/libosmocore/src/fsm.c:337
    #6 0x7f5c3da893a6 in osmo_timers_update /space/home/laforge/projects/git/libosmocore/src/timer.c:273
    #7 0x7f5c3da8cf62 in _osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:373
    #8 0x7f5c3da8d548 in osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:417
    #9 0x55b16ce4705c in main /space/home/laforge/projects/git/osmo-cbc/src/cbc_main.c:216
    #10 0x7f5c3cd63d09 in __libc_start_main ../csu/libc-start.c:308
    #11 0x55b16ce47649 in _start (/space/home/laforge/projects/git/osmo-cbc/src/osmo-cbc+0x2a649)

previously allocated by thread T0 here:
    #0 0x7f5c3e64be8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f5c3d99aecb in __talloc_with_prefix ../../talloc.c:782
    #2 0x7f5c3d99b8a6 in __talloc ../../talloc.c:824
    #3 0x7f5c3d99b8a6 in _talloc_named_const ../../talloc.c:981
    #4 0x7f5c3d99b8a6 in _talloc_zero ../../talloc.c:2422
    #5 0x7f5c3daa4fcd in osmo_fsm_inst_alloc /space/home/laforge/projects/git/libosmocore/src/fsm.c:445
    #6 0x55b16ce4c3c8 in cbsp_cbc_accept_cb /space/home/laforge/projects/git/osmo-cbc/src/cbsp_server.c:127
    #7 0x7f5c3d931288 in osmo_stream_srv_fd_cb /space/home/laforge/projects/git/libosmo-netif/src/stream.c:880
    #8 0x7f5c3da8d1b1 in poll_disp_fds /space/home/laforge/projects/git/libosmocore/src/select.c:350
    #9 0x7f5c3da8d1b1 in _osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:378
    #10 0x7f5c3da8d548 in osmo_select_main /space/home/laforge/projects/git/libosmocore/src/select.c:417
    #11 0x55b16ce4705c in main /space/home/laforge/projects/git/osmo-cbc/src/cbc_main.c:216
    #12 0x7f5c3cd63d09 in __libc_start_main ../csu/libc-start.c:308
    #13 0x55b16ce47649 in _start (/space/home/laforge/projects/git/osmo-cbc/src/osmo-cbc+0x2a649)

Misc

Python tools

Formatting

Checking/analysis

Files (0)

Updated by laforge about 3 years ago · 12 revisions

Add picture from clipboard (Maximum size: 48.8 MB)