Intersections: finish making the debug capture opt-in, follow-up to #387 - #388
Closed
j-modernc-org wants to merge 1 commit into
Closed
j-modernc-org wants to merge 1 commit into
j-modernc-org wants to merge 1 commit into
Conversation
…dewolff#387 Three small gaps left by 0e0d9b2, each with a test that fails without its fix. The globals are still assigned unconditionally, so the flag gates the read and not the write and two goroutines doing boolean path operations still race (they are only ever read from the debug branch, so the assignment can move under the same flag). TestPathIntersectionConcurrent reports a data race at that line under -race without this. os.CreateTemp's error is checked now, but w.Name() is still called outside the else, so a temporary directory that cannot be written dereferences a nil file inside a drawing call. TestPathIntersectionTestCaseNoTempDir covers it. And the captured .gob holds nothing: gob will not encode a value through an interface whose concrete type is not registered, so Encode([]any{...}) fails -- its error dropped too -- and leaves a 12-byte type descriptor on disk. One machine here had 476 such files, all 12 bytes. Since the doc comment asks people to send these in, that is worth having work: the capture now encodes a concrete pathIntersectionTestCase, which needs no registration and can be read back from inside the package with gob.Decode. TestPathIntersectionTestCase writes one through the real code path and decodes it again. The whole capture moves into writePathIntersectionTestCase, so the hot loop carries one call behind the flag rather than the body.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for
0e0d9b2— the two things that hurt an embedder are gone: rendering a real pagenow writes nothing to
/tmpand prints nothing to stdout. (The nil-next-nodepanicbecoming a
LineTooutside debug mode is a bonus for us; a drawing call can no longertake the process down there.)
Three small gaps it left. Each is a couple of lines, each has a test that fails without
its fix, and
go test -race .is green with them.1. The globals are still written unconditionally, so the race remains
bentleyOttmannassigns_ps, _qs, _op, _fillRuleon every call, so the flag gates theread in
breakupCrossingSegmentsand not the write: two goroutines doing boolean pathoperations still race. They are only ever read from the debug branch, so the assignment
moves under the same flag.
Without this,
TestPathIntersectionConcurrent(two goroutines callingPath.And) reports:2.
w.Name()is still called on a nil fileThe error check went in, but the log line stayed outside the
else:(*os.File).Namehas no nil check, so a temporary directory that cannot be written panicsinside a drawing call. Only reachable with the flag on now, but it is the one thing the
error check was added to prevent.
TestPathIntersectionTestCaseNoTempDircovers it.3. The captured
.gobfiles are emptyThis is the one worth having, since the new doc comment asks people to send them in:
As written they carry nothing.
gobwill not encode a value through an interface whoseconcrete type has not been registered, so
Encode([]any{_ps, _qs, _op, _fillRule})failswith
and its error is dropped too — what lands on disk is the 12-byte type descriptor. One
machine here had 476 of these from before the fix, every one 12 bytes.
The capture now encodes a concrete
pathIntersectionTestCaseinstead. That needs noregistration (
Pathalready hasMarshalBinary), and it reads back from inside thepackage with
TestPathIntersectionTestCasewrites one through the real code path — globals set,TMPDIRpointed at a temp dir — and decodes it again, so the format cannot silently rot.Also
The capture body moves into
writePathIntersectionTestCase, so the hot loop carries onecall behind the flag rather than the whole block.
We still have the page content that triggers the branch, and can send you proper captures
for #382 now that the encode works — happy to attach a batch.