Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-9732

Return EINVAL when truncate uses a cursor not owned by the session

    • Storage Engines
    • 3
    • 2024-07-23 - Mining crypto

      Accidentally repro'd this while writing a python test however as the test is very complex it isn't valuable to add it to the ticket.

      The call stack looks like:

      Thread 1 "python" received signal SIGSEGV, Segmentation fault.
      0x00007ffff4eca382 in __wt_log_op (session=0xd58210) at ../src/include/log_inline.h:43
      43          if (!F_ISSET(S2BT(session), WT_BTREE_LOGGED) &&
      (gdb) bt
      #0  0x00007ffff4eca382 in __wt_log_op (session=0xd58210) at ../src/include/log_inline.h:43
      #1  0x00007ffff4ed0594 in __wt_btcur_range_truncate (start=0xe10900, stop=0xe77260)
          at ../src/btree/bt_cursor.c:2121
      #2  0x00007ffff50a68bc in __wt_schema_range_truncate (session=0xd57dd0, start=0xe10900,
          stop=0xe77260) at ../src/schema/schema_truncate.c:173
      #3  0x00007ffff50b720e in __wt_session_range_truncate (session=0xd57dd0, uri=0x0,
          start=0xe10900, stop=0xe77260) at ../src/session/session_api.c:1454
      #4  0x00007ffff50b7e57 in __session_truncate (wt_session=0xd57dd0, uri=0x0, start=0xe10900,
          stop=0xe77260, config=0x0) at ../src/session/session_api.c:1521
      #5  0x00007ffff53cd9d6 in _wrap_Session_truncate (self=0x7ffff5e3f1d0, args=0x7ffff44c4830)
          at lang/python/CMakeFiles/wiredtiger_python.dir/wiredtigerPYTHON_wrap.c:7135
       

      Effectively truncate calls __wt_log_op to determine whether the truncate should be logged. Inside of __wt_log_op we call S2BT which tries to get the btree from the session->dhandle->handle which can be NULL. Thus we segfault.

            Assignee:
            andrew.morton@mongodb.com Andrew Morton
            Reporter:
            luke.pearson@mongodb.com Luke Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: