Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2608

libbson and mongoc tests crash in libbson code when using --no-fork

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.10.0
    • Affects Version/s: 1.9.3, 1.9.4
    • Component/s: libbson
    • None
    • Environment:
      AIX - GCC v6 and v7

      Hi,

      I'm porting mongoc/libbson on AIX (v6.1). First port.

      I've started with version 1.9.3. I've just moved to version 1.9.4 .

      The "make check" generates crashes (core) for libbson and mongoc, both with -O2 and -g, both in 32bit and 64bit (however, crashes are different).

      "make check" makes use of the "--no-fork" option. When not using this option, mongoc shows only 6 FAILures, no crash/core, and libbson is OK.

      I've tried with libbson bundled or not inside mongoc: nearly the same crashes.

      libbson/mongoc are compiled with GCC, v6.3 at first, now v7.1 .

      Since MongoDB does not run on AIX, I'm using a remote mongodb server on a Linux/x86_64 machine (4.13.11-100.fc25.x86_64).
      MongoDB version : mongodb-server-3.2.12-1.fc25.x86_64

      It seems to me that the crashes deal with how libbson manages memory:
      bson_mem_restore_vtable
      bson_malloc0
      _bson_iter_next_internal
      bson_string_new

      I know nearly nothing about mongoc. I need help for figuring out how to debug/fix this issue.

      About mongoc, I have:
      {{libmongoc 1.9.4 was configured with the following options:

      Build configuration:
      Enable debugging (slow) : yes
      Compile with debug symbols (slow) : full
      Enable GCC build optimization : no
      Enable automatic init and cleanup : no
      Enable mongodb+srv URIs : auto
      Enable maintainer flags : no
      Code coverage support : no
      Cross Compiling : no
      Fast counters : no
      Shared memory performance counters : yes
      SASL : no
      SSL : openssl
      Snappy Compression : system
      Zlib Compression : system
      Libbson : system

      Documentation:
      man : no
      HTML : no}}

      1. gdb ./test-libmongoc
        (gdb) run (no --no-fork option !)
        { "status": "FAIL", "test_file": "/BulkOperation/upsert_unordered_oversized", "seed": "10627911", "start": 10987519.621764589, "end": 10987521.316436900, "elapsed": 1.694672311 }

        ,

        { "status": "FAIL", "test_file": "/BulkOperation/upsert_huge", "seed": "3030471911", "start": 10987522.620592515, "end": 10987523.967977921, "elapsed": 1.347385406 }

        ,

        { "status": "FAIL", "test_file": "/BulkOperation/large_inserts_ordered", "seed": "3138342737", "start": 10987531.721175652, "end": 10987533.140875839, "elapsed": 1.419700187 }

        ,

        { "status": "FAIL", "test_file": "/BulkOperation/large_inserts_unordered", "seed": "3327859616", "start": 10987533.141157775, "end": 10987534.537897308, "elapsed": 1.396739533 }

        ,

        { "status": "FAIL", "test_file": "/Collection/update/oversize", "seed": "3143947750", "start": 10987579.365100689, "end": 10987581.035526324, "elapsed": 1.670425635 }

        ,

        { "status": "FAIL", "test_file": "/TOPOLOGY/scanner_connection_error", "seed": "1693182082", "start": 10987742.630362888, "end": 10987742.752703433, "elapsed": 0.122340545 }

        ,

      (gdb) run --no-fork
      ...

      { "status": "PASS", "test_file": "/BulkOperation/upsert_ordered", "seed": "2340171206", "start": 10987861.810715472, "end": 10987861.863608857, "elapsed": 0.052893385 }

      ,

      { "status": "PASS", "test_file": "/BulkOperation/upsert_unordered", "seed": "4266335484", "start": 10987861.863814916, "end": 10987861.915511878, "elapsed": 0.051696962 }

      ,

      0x09000000004dce94 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5_64.o)
      (gdb) where
      #0 0x09000000004dce94 in pthread_kill () from /usr/lib/libpthreads.a(shr_xpg5_64.o)
      #1 0x09000000004dc6cc in _p_raise () from /usr/lib/libpthreads.a(shr_xpg5_64.o)
      #2 0x090000000002c550 in raise () from /usr/lib/libc.a(shr_64.o)
      #3 0x0900000000082fe8 in abort () from /usr/lib/libc.a(shr_64.o)
      #4 0x0900000001ab18d4 in bson_mem_restore_vtable () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #5 0x0900000001ab1944 in memset () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #6 0x0900000001aa7424 in _bson_data () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #7 0x0900000001aa74f4 in _bson_encode_length () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #8 0x0900000001aa772c in _bson_append () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #9 0x0900000001aa79d4 in _bson_append_bson_begin () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #10 0x0900000001aaad04 in bson_append_timestamp () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #11 0x0900000001ac6148 in jsonsl_enable_all_callbacks () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #12 0x0900000001aca8c8 in _bson_json_read_append_dbpointer () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #13 0x0900000001acd59c in bson_json_reader_new_from_fd () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #14 0x0900000001acadb0 in _bad_extended_json () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #15 0x0900000001acb580 in _bson_json_read_end_map () from /opt/freeware/lib/libbson-1.0.a(libbson-1.0.so.0)
      #16 0x0000000100080f64 in tmp_bson (json=0xffffffffffff080 "") at tests/test-conveniences.c:94
      #17 0x00000001000bae70 in test_upsert_unordered_oversized (ctx=0x8) at tests/test-mongoc-bulk.c:585
      #18 0x00000001000855a0 in TestSuite_RunTest (suite=<incomplete type>, test=0x11007ed10, count=0xffffffffffff54c) at tests/TestSuite.c:686
      #19 0x0000000100085f1c in TestSuite_RunSerial (suite=<incomplete type>) at tests/TestSuite.c:951
      #20 0x0000000100086420 in TestSuite_Run (suite=<incomplete type>) at tests/TestSuite.c:1046
      #21 0x000000010000562c in main (argc=2, argv=0xffffffffffff740) at tests/test-libmongoc.c:2179

      libbson bundled within mongoc :

      1. gmake check ---->> ./test-libbson --threads --no-fork
        ...
        { "status": "PASS", "test_file": "/version", "seed": "254312888", "start": 10984479.058313609, "end": 10984479.058315300, "elapsed": 0.000001691 }

        ,

        { "status": "PASS", "test_file": "/bson/writer/custom_realloc", "seed": "2005447092", "start": 10984479.058322513, "end": 10984479.058329431, "elapsed": 0.000006918 }

        ,
        /bin/sh[2]: 24248364 Memory fault(coredump)

      1. cd ./src/libbson
      2. gdb ./.libs/lt-test-libbson core
        Core was generated by `lt-test-libbson'.
        Program terminated with signal SIGSEGV, Segmentation fault.
        #0 0x090000000001057c in calloc_common () from /usr/lib/libc.a(shr_64.o)
        (gdb) where
        #0 0x090000000001057c in calloc_common () from /usr/lib/libc.a(shr_64.o)
        #1 0x09000000019a5bac in bson_string_new () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #2 0x09000000019a7958 in bson_utf8_escape_for_json () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #3 0x090000000199cc4c in _bson_as_json_visit_before () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #4 0x09000000019a3f4c in bson_iter_visit_all () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #5 0x090000000199d290 in _bson_as_json_visit_document () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        ...
        #404 0x09000000019a4220 in bson_iter_visit_all () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #405 0x090000000199d680 in _bson_as_json_visit_all () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #406 0x090000000199d818 in bson_as_json () from /opt/freeware/src/packages/BUILD/mongo-c-driver-1.9.4/64bit/src/libbson/.libs/libbson-1.0.a(libbson-1.0.so.0)
        #407 0x000000010002dfa8 in test_bson_as_json_stack_overflow () at tests/test-json.c:671
        #408 0x00000001000010cc in TestSuite_AddHelper (cb_=0x110001f20 <ccl3836H.rw+4528>) at tests/TestSuite.c:304
        #409 0x00000001000017d0 in TestSuite_RunTest (suite=0xfffffffffffeeb8, test=0x110038770, mutex=0xfffffffffffed38, count=0xfffffffffffed78) at tests/TestSuite.c:481
        #410 0x0000000100001df4 in TestSuite_ParallelWorker (data=0x110057d10) at tests/TestSuite.c:675
        #411 0x09000000004c4d34 in _pthread_body () from /usr/lib/libpthread.a(shr_xpg5_64.o)
        #412 0x0000000000000000 in ?? ()
        (gdb)

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            trex58 Tony Reix
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: