-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
We've noticed that certain race conditions could occur when we use this library to process a high volume of passes using an in-memory pass template. Although I intended to submit this issue with an associated PR to resolve the problem, I realized this might require more work than expected, so I'm submitting the issue in advance and potentially creating a PR later.
This is one of the race conditions we've found when loading assets from a URL:
==================
WARNING: DATA RACE
Write at 0x00c000472000 by goroutine 10:
runtime.mapaccess2_faststr()
../1.22.8/go/src/runtime/map_faststr.go:108 +0x42c
github.com/alvinbaena/passkit.(*InMemoryPassTemplate).AddFileFromURL()
../go/pkg/mod/github.com/alvinbaena/passkit@v0.0.0-20231118075341-79567105cd75/templates.go:140 +0x88There's another one when signing a pass:
github.com/alvinbaena/passkit.(*memorySigner).CreateSignedAndZippedPassArchive(0xc00047c2d0?, 0x1871450?, {0x186aa18?, 0xc003746030?}, 0xe?)
/go/pkg/mod/github.com/alvinbaena/passkit@v0.0.0-20231118075341-79567105cd75/mem_signer.go:28 +0x157
github.com/alvinbaena/passkit.(*memorySigner).CreateSignedAndZippedPersonalizedPassArchive(0x23ae720, 0xc005147008, 0x0, {0x186aa18?, 0xc003746030?}, 0xc0038fe320)
/go/pkg/mod/github.com/alvinbaena/passkit@v0.0.0-20231118075341-79567105cd75/mem_signer.go:115
github.com/alvinbaena/passkit.(*memorySigner).makeFilesCopy(...)
goroutine 217 [running]:
fatal error: concurrent map iteration and map writeWe solved those problems using an external mutex. Still, we could make the in-memory template concurrency-safe by using a mutex to protect the InMemoryPassTemplate.files internal map.
Metadata
Metadata
Assignees
Labels
No labels