Skip to content

Conversation

@quinnj
Copy link
Member

@quinnj quinnj commented Oct 10, 2025

Full implementation of the idea/discussion in #391 . This ensures our buf is GC-preserved before every call to parsestring and the preservation lasts until the PtrString goes out of scope.

Many thanks to @yuyichao for helping around this issue.

@quinnj quinnj mentioned this pull request Oct 10, 2025
@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.99%. Comparing base (cba1b4a) to head (501cc88).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #395      +/-   ##
==========================================
+ Coverage   89.89%   89.99%   +0.09%     
==========================================
  Files           7        7              
  Lines        1316     1329      +13     
==========================================
+ Hits         1183     1196      +13     
  Misses        133      133              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

elseif T == JSONTypes.STRING
str, _ = parsestring(x)
Base.print(io, "JSON.LazyValue(", repr(convert(String, str)), ")")
buf = getbuf(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since buf isn't explicitly used and getbuf is just an accessor, GC.@preserve x is probably more clear in this case. The main difference is that the other fields of x would also be preserved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so GC.@preserve x will ensure the field is also preserved?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will assume the whole object is being used in some unknown way, which includes the field.

For mutable object, this implies the object address may be used (though there’s no requirement for that address to be allocated in the heap). For immutable object this only implies that the fields are all being used in some unknown way.

@quinnj quinnj merged commit f50d454 into master Oct 10, 2025
12 checks passed
@quinnj quinnj deleted the jq-gc-preserve branch October 10, 2025 21:58
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.

3 participants