)]}'
{
  "commit": "8bcda98da5db9003145674d8a7cbe7b81cab0d24",
  "tree": "0201342cfe9bfb12adcbd8de9e2b57c3dc32737e",
  "parents": [
    "5d213e46bb7b880238ff5ea3914e940a50ae9369"
  ],
  "author": {
    "name": "René Scharfe",
    "email": "l.s.r@web.de",
    "time": "Sat Aug 14 22:00:38 2021 +0200"
  },
  "committer": {
    "name": "Junio C Hamano",
    "email": "gitster@pobox.com",
    "time": "Sun Aug 15 13:13:50 2021 -0700"
  },
  "message": "oidtree: avoid unaligned access to crit-bit tree\n\nThe flexible array member \"k\" of struct cb_node is used to store the key\nof the crit-bit tree node.  It offers no alignment guarantees -- in fact\nthe current struct layout puts it one byte after a 4-byte aligned\naddress, i.e. guaranteed to be misaligned.\n\noidtree uses a struct object_id as cb_node key.  Since cf0983213c (hash:\nadd an algo member to struct object_id, 2021-04-26) it requires 4-byte\nalignment.  The mismatch is reported by UndefinedBehaviorSanitizer at\nruntime like this:\n\nhash.h:277:2: runtime error: member access within misaligned address 0x00015000802d for type \u0027struct object_id\u0027, which requires 4 byte alignment\n0x00015000802d: note: pointer points here\n 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00\n             ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior hash.h:277:2 in\n\nWe can fix that by:\n\n1. eliminating the alignment requirement of struct object_id,\n2. providing the alignment in struct cb_node, or\n3. avoiding the issue by only using memcpy to access \"k\".\n\nCurrently we only store one of two values in \"algo\" in struct object_id.\nWe could use a uint8_t for that instead and widen it only once we add\nsupport for our twohundredth algorithm or so.  That would not only avoid\nalignment issues, but also reduce the memory requirements for each\ninstance of struct object_id by ca. 9%.\n\nSupporting keys with alignment requirements might be useful to spread\nthe use of crit-bit trees.  It can be achieved by using a wider type for\n\"k\" (e.g. uintmax_t), using different types for the members \"byte\" and\n\"otherbits\" (e.g. uint16_t or uint32_t for each), or by avoiding the use\nof flexible arrays like khash.h does.\n\nThis patch implements the third option, though, because it has the least\npotential for causing side-effects and we\u0027re close to the next release.\nIf one of the other options is implemented later as well to get their\nadditional benefits we can get rid of the extra copies introduced here.\n\nReported-by: Andrzej Hunt \u003candrzej@ahunt.org\u003e\nSigned-off-by: René Scharfe \u003cl.s.r@web.de\u003e\nSigned-off-by: Junio C Hamano \u003cgitster@pobox.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fe4587087e8820268e746eecd289c5fc0ea9ca10",
      "old_mode": 33188,
      "old_path": "cbtree.h",
      "new_id": "a04a312c3f5bd14873e96edc227524a2245c6c35",
      "new_mode": 33188,
      "new_path": "cbtree.h"
    },
    {
      "type": "modify",
      "old_id": "27a180248f96fd4cf394b059ed92b02bcaeebc7b",
      "old_mode": 33188,
      "old_path": "hash.h",
      "new_id": "9e25c40e9accf514ea42a1b445f86551f7a46aa3",
      "new_mode": 33188,
      "new_path": "hash.h"
    },
    {
      "type": "modify",
      "old_id": "580cab8ae27e08285d8a57cf55d95660072dcd53",
      "old_mode": 33188,
      "old_path": "oidtree.c",
      "new_id": "0d39389bee29be3f0496185331df1ac85f87003b",
      "new_mode": 33188,
      "new_path": "oidtree.c"
    }
  ]
}
