golang protobuf APIv2 - lock on init() related to registration

33 views
Skip to first unread message

Mark Wardle

unread,
Mar 4, 2020, 4:48:31 PM3/4/20
to Protocol Buffers
Hi. I've upgraded to the new Go protobuf implementation (https://blog.golang.org/a-new-go-api-for-protocol-buffers) and am getting a locked thread on startup, due a lock being requested in init(). Truncated stack trace :

goroutine 1 [semacquire, locked to thread]:
sync.runtime_SemacquireMutex(0x1b137dc, 0xc0001cd700, 0x0)
/usr/local/Cellar/go/1.14/libexec/src/runtime/sema.go:71 +0x47
sync.(*RWMutex).RLock(...)
/usr/local/Cellar/go/1.14/libexec/src/sync/rwmutex.go:50

// This returns (nil, NotFound) if not found.
func (r *Files) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) {
if r == nil {
return nil, NotFound
}
if r == GlobalFiles {
globalMutex.RLock()
defer globalMutex.RUnlock()
}
prefix := name
.....

I am not sure what is going on here and not sure how to start investigating, or whether there's some incompatibility with my toolchain and module versions.

Has anyone come across this issue? Thanks,

Mark

tandr

unread,
Mar 5, 2020, 1:15:44 PM3/5/20
to Protocol Buffers
Mark,

you might want to open a bug on their bug tracker.


On Wednesday, March 4, 2020 at 2:48:31 PM UTC-7, Mark Wardle wrote:
Hi. I've upgraded to the new Go protobuf implementation (https://blog.golang.org/a-new-go-api-for-protocol-buffers) and am getting a locked thread on startup, due a lock being requested in init(). Truncated stack trace :
 
<unreadable colorful stuff removed>

Mark Wardle

unread,
Mar 5, 2020, 1:16:22 PM3/5/20
to Protocol Buffers


On Thursday, 5 March 2020 18:15:44 UTC, tandr wrote:
Mark,

you might want to open a bug on their bug tracker.


Will do. Thanks
 

Mark Wardle

unread,
Mar 5, 2020, 3:51:20 PM3/5/20
to Protocol Buffers
So this is now fixed. For anyone else who encounters this with golang protobuf 1.20 APIv2, I modified go.mod to include the latest release from github as a temporary fix:

google.golang.org/protobuf v0.0.0-20200305173516-13e7f145cc57

instead of


because this deadlock fixed in commit : 

It's basically a deadlock on registration / initialisation of a descriptor.

Mark

Joe Tsai

unread,
Mar 10, 2020, 4:26:55 AM3/10/20
to Protocol Buffers
Reply all
Reply to author
Forward
0 new messages