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

wt dump index:... causes segfault in __wt_raw_to_esc_hex

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Can reproduce reliably on OSX. First run:

      #define CHK(x) do {							\
      	int __ret;							\
      	if ((__ret = (x)) != 0) {					\
      		fprintf(stderr, "ERROR at %s:%d: %s\n",			\
      		    __FILE__, __LINE__, wiredtiger_strerror(__ret));	\
      		exit(1);						\
      	}								\
      } while(0)
      ...
      	home = "WT_HOME";
      	CHK(system("rm -rf WT_HOME && mkdir WT_HOME"));
      	CHK(wiredtiger_open(home, NULL, "create", &conn));
      	CHK(conn->open_session(conn, NULL, NULL, &session));
      	CHK(session->create(session, "table:main",
      	    "key_format=i,value_format=i," "columns=(key,val)"));
              CHK(session->create(session, "index:main:ikey", "columns=(key)"));
              CHK(session->open_cursor(session, "table:main", NULL, NULL, &cursor));
       
      	for (i = 1; i <= 3; i++) {
      		sq = i*i;
      		cube = i*i*i;
      		cursor->set_key(cursor, i);
      		cursor->set_value(cursor, sq, cube);
      		CHK(cursor->insert(cursor));
      	}
              CHK(cursor->close(cursor));
              CHK(session->close(session, NULL));
              CHK(conn->close(conn, NULL));
      

      Then dump the index using wt from the shell:

      $ ../build_posix/.libs/wt -h WT_HOME/ dump index:main:ikey
      WiredTiger Dump (WiredTiger Version 2.5.1)
      Format=print
      Header
      index:main:ikey
      allocation_size=4KB,app_metadata=,block_allocation=best,block_compressor=,cache_resident=0,checksum=uncompressed,colgroups=,collator=,columns=(key),dictionary=0,exclusive=0,extractor=,format=btree,huffman_key=,huffman_value=,immutable=0,internal_item_max=0,internal_key_max=0,internal_key_truncate=,internal_page_max=4KB,key_format=i,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,lsm=(auto_throttle=,bloom=,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=0,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_max=15,merge_min=0),memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=0,prefix_compression_min=4,source="file:main_ikey.wti",split_deepen_min_child=0,split_deepen_per_child=0,split_pct=75,type=file,value_format=
      Data
      Segmentation fault: 11
      $
      

      For some odd reason, running lldb or gdb directly on ../build_posix/.libs/wt does not show the problem for me (the command completes with expected output). However, attaching the debugger works:

      * thread WT-1: tid = 0x1350c3d, 0x0000000109f2d012 libwiredtiger-2.5.1.dylib`__wt_raw_to_esc_hex(session=0x00007fd682808500, from=0x00007fd600000001, size=1, to=0x00007fd682500290) + 130 at hex.c:80, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7fd600000001)
          frame #0: 0x0000000109f2d012 libwiredtiger-2.5.1.dylib`__wt_raw_to_esc_hex(session=0x00007fd682808500, from=0x00007fd600000001, size=1, to=0x00007fd682500290) + 130 at hex.c:80
         77  		 * trailing nul byte.
         78  		 */
         79  		for (p = from, t = to->mem, i = size; i > 0; --i, ++p)
      -> 80  			if (isprint((int)*p)) {
         81  				if (*p == '\\')
         82  					*t++ = '\\';
         83  				*t++ = *p;
      (lldb) p p
      (const uint8_t *) $10 = 0x00007fd600000001 ""
      (lldb) x/20x p
      error: memory read failed for 0x7fd600000000
      (lldb) p from
      (const uint8_t *) $12 = 0x00007fd600000001 ""
      (lldb) up
      frame WT-1: 0x0000000109e91ba9 libwiredtiger-2.5.1.dylib`__raw_to_dump(session=0x00007fd682808500, from=0x00007fff55e0bef0, to=0x00007fd682500290, hexonly=0) + 137 at cur_dump.c:23
         20  		if (hexonly)
         21  			WT_RET(__wt_raw_to_hex(session, from->data, from->size, to));
         22  		else
      -> 23  			WT_RET(
         24  			    __wt_raw_to_esc_hex(session, from->data, from->size, to));
         25
         26  		return (0);
      (lldb) p *from
      (WT_ITEM) $13 = (data = const void * = 0x00007fd600000001, size = 1, flags = 0, mem = void * = 0x0000000000000000, memsize = 140559289189632)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              donald.anderson Donald Anderson
              Reporter:
              donald.anderson Donald Anderson
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: