Skip to content

mempool element and block size pathology #70

Description

@JohnMcHugh

It appears to be possible to specify mempool elements that are larger than the blocks which should contain them.

The place where these come together is in the mempool creation routine cork_mempool_new_size_ex. At the very least, the problem could be diagnosed there, taking into account the need to provide both block and element headers. Possible solutions include:

  1. Modifying the documentation to call attention to the erroneous usage. This, alone, leaves open the possibility of difficult to diagnose segmentation faults at run time. It also requires exposing the block and element structures with their otherwise invisible header / link fields.
  2. Including a test in cork_mempool_new_size_ex that will abort the computation if the pathology occurs. If this is done, the diagnostic should specify the minimum block size required to hold a single element of the desired size.
  3. Allowing the code to adjust the block size, if necessary, so that a block will hold at least one element with the necessary header / link fields. Note that this might be extended so that a block will always hold an integral number of elements. It is not clear that this offers other than aesthetic benefits, although, a user naively specifying a block that is an integral multiple of the user's element size ensures a, possibly significant, waste of space due to the header / link space required.
  4. Introduce an incompatible change that replaces the block size specification with an element count specification. With this change, a default element count would replace the current default block size specification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions