)]}'
{
  "commit": "0ead11a53105d3e6db90eac98f8dd78a629f70c0",
  "tree": "864a8e4600b4bb5c4f4589d7b0d989c161a8f9b9",
  "parents": [
    "12a1eb7c63c644316b0eded9fc939def05ce4b5a"
  ],
  "author": {
    "name": "Evan Jones",
    "email": "evan.jones@datadoghq.com",
    "time": "Fri Mar 05 21:55:31 2021"
  },
  "committer": {
    "name": "Evan Jones",
    "email": "evan.jones@datadoghq.com",
    "time": "Fri Mar 05 22:04:34 2021"
  },
  "message": "Fix \"Go pointer to Go pointer\" panics\n\nThe Cgo runtime verifies that Go never passes pointers to other Go\npointers, which is required for correct garbage collection.\nUnfortunately, its checks are not perfect, and there are occasional\nfalse positives. Our code triggers these false positives if the\nslice passed to compression functions is in the same memory\nallocation as Go pointers. This happened when trying to use zstd with\nanother package\u0027s Writer type, which has an internal buffer.\n\nThe tests added in this PR all fail with the following panic. The\nfix is to ensure the expression unsafe.Pointer(\u0026src[0]) is inside the\nCgo call, and not before. This is documented in the following issue:\n\nhttps://github.com/golang/go/issues/14210#issuecomment-346402945\n\nThe remaining uses of the \"var srcPtr *byte\" pattern are safe: they\nall pass the address of a byte slice that is allocated internally by\nthis library, so I believe they cannot cause this error.\n\nFixes the following panic:\n\npanic: runtime error: cgo argument has Go pointer to Go pointer\n\ngoroutine 30 [running]:\npanic(...)\n  /usr/local/go/src/runtime/panic.go:969 +0x1b9\ngithub.com/DataDog/zstd.(*ctx).CompressLevel.func1(...)\n  /home/circleci/project/zstd_ctx.go:75 +0xd9\ngithub.com/DataDog/zstd.(*ctx).CompressLevel(...)\n  /home/circleci/project/zstd_ctx.go:75 +0xce\ngithub.com/DataDog/zstd.TestCtxCompressLevelNoGoPointers.func1(...)\n  /home/circleci/project/zstd_ctx_test.go:71 +0x77\ngithub.com/DataDog/zstd.testCompressNoGoPointers(...)\n  /home/circleci/project/zstd_test.go:130 +0xad\ngithub.com/DataDog/zstd.TestCtxCompressLevelNoGoPointers(...)\n  /home/circleci/project/zstd_ctx_test.go:69 +0x37\ntesting.tRunner(...)\n  /usr/local/go/src/testing/testing.go:1123 +0xef\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "164a923bfa66f962e886e29736e1d1765154c81b",
      "old_mode": 33188,
      "old_path": "zstd.go",
      "new_id": "634ed653c0897f259e9daa5a89aa6885ff2565d9",
      "new_mode": 33188,
      "new_path": "zstd.go"
    },
    {
      "type": "modify",
      "old_id": "12e953971a9247c1c6fc01886f2114db36586383",
      "old_mode": 33188,
      "old_path": "zstd_ctx.go",
      "new_id": "6b98943f7cff3bc34a27fe19d82a0128255b91cc",
      "new_mode": 33188,
      "new_path": "zstd_ctx.go"
    },
    {
      "type": "modify",
      "old_id": "831a21faf0d1a8e3cbf8a968e7c7b3d81843f9b6",
      "old_mode": 33188,
      "old_path": "zstd_ctx_test.go",
      "new_id": "ac82091cc4effcb6183250e1d1e03bf8575e99a2",
      "new_mode": 33188,
      "new_path": "zstd_ctx_test.go"
    },
    {
      "type": "modify",
      "old_id": "1ed0e98577bc538fbf513057204abc9f3f5b680f",
      "old_mode": 33188,
      "old_path": "zstd_stream.go",
      "new_id": "ac0a23a339d22b93ef7bce354f5779f5e1ca571e",
      "new_mode": 33188,
      "new_path": "zstd_stream.go"
    },
    {
      "type": "modify",
      "old_id": "06acece53ed3ec01fbc5d32b27bcda742ce38560",
      "old_mode": 33188,
      "old_path": "zstd_stream_test.go",
      "new_id": "79f412e014cdd0ce5d13580fe7269110a81706ee",
      "new_mode": 33188,
      "new_path": "zstd_stream_test.go"
    },
    {
      "type": "modify",
      "old_id": "e4d90c8a94b8af96ba046f211970a18f46915d92",
      "old_mode": 33188,
      "old_path": "zstd_test.go",
      "new_id": "e5bb2d2e99c4cc3572ca3febf71ccf90da3f918d",
      "new_mode": 33188,
      "new_path": "zstd_test.go"
    }
  ]
}
