|
66 | 66 | // |
67 | 67 | // Always run the tests with the -race flag (or -tags debug). Both set |
68 | 68 | // deadlock.Debug, which enables the debug-gated runtime invariant checks: the |
69 | | -// lock-order verification described above, the late-handler panic, and the |
70 | | -// tag-comparability check in [github.com/linkdata/jaws/lib/tag]. Those branches |
71 | | -// are compile-time dead in normal builds, so a plain "go test" neither |
72 | | -// exercises them nor reports their statement coverage. CI builds with |
| 69 | +// lock-order verification described above and the late-handler panic. Those |
| 70 | +// branches are compile-time dead in normal builds, so a plain "go test" neither |
| 71 | +// exercises them nor reports their statement coverage. Runtime tag-comparability |
| 72 | +// checks in [github.com/linkdata/jaws/lib/tag] run in every build. CI builds with |
73 | 73 | // -tags debug -race. |
74 | 74 | package jaws |
75 | 75 |
|
@@ -759,11 +759,9 @@ func (jw *Jaws) Broadcast(msg wire.Message) { |
759 | 759 | // [Jaws.reportMisuse], if any tag is not comparable at runtime. |
760 | 760 | // |
761 | 761 | // Expanded tags become map keys in the processing loop (wantMessage's lookup in |
762 | | -// Request.tagMap). A value can pass tag expansion's static comparability check yet |
763 | | -// be non-comparable at runtime (a comparable struct holding e.g. a func in an |
764 | | -// interface field), which panics when hashed. [tag.NewErrNotComparable] runs the |
765 | | -// runtime value check that ensureUsableTag only performs in debug builds, so this |
766 | | -// rejects a bad Dest before it can panic the Serve goroutine and crash the process. |
| 762 | +// Request.tagMap). TagExpand rejects the known runtime-non-comparable |
| 763 | +// struct/array case, and this guard remains as a final defense before a bad Dest |
| 764 | +// can panic the Serve goroutine and crash the process. |
767 | 765 | func (jw *Jaws) dropNonComparableTags(tags []any) []any { |
768 | 766 | for _, tagValue := range tags { |
769 | 767 | if cmperr := tag.NewErrNotComparable(tagValue); cmperr != nil { |
@@ -793,14 +791,13 @@ func (jw *Jaws) setDirty(tags []any) { |
793 | 791 | // Note that if any of the tags implement [tag.TagGetter], it will be called |
794 | 792 | // with a nil [Request]. Prefer using [Request.Dirty] which avoids this. |
795 | 793 | // |
796 | | -// A tag that is comparable statically but not at runtime (a comparable struct |
797 | | -// holding e.g. a func in an interface field) panics the calling goroutine when |
798 | | -// hashed as a map key, in non-debug builds where the expansion check is skipped. |
799 | | -// The panic is contained to the caller (the lock is released and the [Jaws.Serve] |
800 | | -// loop is unaffected); it is not logged-and-dropped the way [Jaws.Broadcast] |
801 | | -// handles such a [wire.Message.Dest], because that hashing happens in the Serve |
802 | | -// goroutine where a panic would crash the process. [Request.Dirty] behaves the |
803 | | -// same as Dirty here. |
| 794 | +// A tag that somehow passes expansion but is still not hashable panics the |
| 795 | +// calling goroutine when hashed as a map key. The panic is contained to the |
| 796 | +// caller (the lock is released and the [Jaws.Serve] loop is unaffected); it is |
| 797 | +// not logged-and-dropped the way [Jaws.Broadcast] handles such a |
| 798 | +// [wire.Message.Dest], because that hashing happens in the Serve goroutine where |
| 799 | +// a panic would crash the process. [Request.Dirty] behaves the same as Dirty |
| 800 | +// here. |
804 | 801 | func (jw *Jaws) Dirty(dirtyTags ...any) { |
805 | 802 | // Use TagExpand+MustLog rather than MustTagExpand: with a nil Context the |
806 | 803 | // latter panics on an illegal tag even in production, unlike the sibling |
|
0 commit comments