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

Cast involving volatile to no effect in assertion

    • Storage Engines
    • 1
    • StorEng - Defined Pipeline

      Introduced in PR 9208 this assert at or near to src/include/btree_inline.h:1562 uses volatile in an apparent attempt to ensure ref->addr is explicitly loaded from memory.

      WT_ASSERT(session, (volatile void *)ref->addr != NULL);
      

      However this cast indicates the memory addr is pointing to is volatile, rather than pointer. The value of the pointer is then tested which is not volatile.

      I believe the pointer needs to be cast a to a volatile pointer and then dereferenced.

      WT_ASSERT(session, *(void * volatile *)&ref->addr != NULL);
      

      I think (tentatively) this is required 6.7.3 of the C11/C17 specifications.

            Assignee:
            y.ershov@mongodb.com Yury Ershov
            Reporter:
            marc.butler@mongodb.com Marc Butler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: