Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data race with concurrent reads across Reader.File #15

Open
wizardishungry opened this issue Sep 5, 2024 · 1 comment
Open

Data race with concurrent reads across Reader.File #15

wizardishungry opened this issue Sep 5, 2024 · 1 comment

Comments

@wizardishungry
Copy link

wizardishungry commented Sep 5, 2024

func TestConcurrentAccess(t *testing.T) {
	file, _ := os.Open("../../testdata/cool_images.doc") // a file with small number of embedded images
	defer file.Close()
	doc, err := mscfb.New(file)
	if err != nil {
		log.Fatal(err)
	}
	var wg sync.WaitGroup
	wg.Add(len(doc.File))
	for _, f := range doc.File {
		go func() {
			defer wg.Done()
			_, err := io.Copy(io.Discard, f)
			if err != nil {
				log.Println(err)
			}
		}()
	}
	wg.Wait()
}

Race is on r.buf in mscfb.(*Reader).readAt()

	if _, err := r.ra.ReadAt(r.buf[:length], offset); err != nil {
@richardlehane
Copy link
Owner

thanks for this report @wizardishungry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants