Skip to content

Conversation

@tjgq
Copy link
Contributor

@tjgq tjgq commented Jul 12, 2024

Raw_New borrows a reference to its PyBytesObject argument, so Raw_Copy must still dispose of it.

The following is a minimal repro for this issue:

import msgspec

DECODER = msgspec.msgpack.Decoder(type=msgspec.Raw)
PAYLOAD = b"\xda\xff\xff" + (65535 * b"\0") # array of 65535 zeros

for _ in range(1000000):
  raw = DECODER.decode(PAYLOAD)
  raw.copy()

@tjgq tjgq marked this pull request as ready for review July 12, 2024 19:15
@tjgq
Copy link
Contributor Author

tjgq commented Jul 15, 2024

@jcrist could you please take a look?

tjgq and others added 2 commits October 13, 2024 12:41
Raw_New borrows a reference to its PyBytesObject argument, so Raw_Copy must
still dispose of it.

The following is a minimal repro for this issue:

import msgspec

DECODER = msgspec.msgpack.Decoder(type=msgspec.Raw)
PAYLOAD = b"\xda\xff\xff" + (65535 * b"\0") # array of 65535 zeros

for _ in range(1000000):
  raw = DECODER.decode(PAYLOAD)
  raw.copy()
@jcrist jcrist merged commit 51a261c into jcrist:main Oct 13, 2024
7 checks passed
@jcrist
Copy link
Owner

jcrist commented Oct 13, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants