printlock increments mp.locks. When mp.locks is not zero the M can't
> Wondering is it intentional behavior? As print* are (almostly if not always) used in runtime during STW or guarded by high level locks.
>
> I didn't figure out how to produce a deadlock by user testcase, but the change below could easily deadlock 'go_bootstrap' when running './src/make.bash'.
>
> A similar issue was opened in
https://github.com/golang/go/issues/54786, but no follow-up for months.
>
> Thanks.
>
> ```
> diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go
> index 6ccf090ac5..3336823dc0 100644
> --- a/src/runtime/mgcsweep.go
> +++ b/src/runtime/mgcsweep.go
> @@ -155,6 +155,7 @@ func (a *activeSweep) begin() sweepLocker {
> return sweepLocker{mheap_.sweepgen, false}
> }
> if a.state.CompareAndSwap(state, state+1) {
> + println("activeSweep.begin, old:", state, ",new:", state+1)
> return sweepLocker{mheap_.sweepgen, true}
> }
> }
> @@ -172,6 +173,7 @@ func (a *activeSweep) end(sl sweepLocker) {
> throw("mismatched begin/end of activeSweep")
> }
> if a.state.CompareAndSwap(state, state-1) {
> + println("activeSweep.end, old:", state, ",new:", state-1)
> if state != sweepDrainedMask {
> return
> }
> ```
>
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to