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

Concurrent map writes error when calling faker in parrallel #5

Closed
huydinhle opened this issue Sep 10, 2022 · 2 comments · Fixed by #6
Closed

Concurrent map writes error when calling faker in parrallel #5

huydinhle opened this issue Sep 10, 2022 · 2 comments · Fixed by #6

Comments

@huydinhle
Copy link

package main

import (
	"fmt"
  "sync"
  "github.com/go-faker/faker/v4"

)

func main() {
	var wg sync.WaitGroup
	wg.Add(1000)
	fmt.Println("Running for loop…")
	for i := 0; i < 1000; i++ {
		go func(i int) {
			defer wg.Done()
      fmt.Println(  fmt.Sprintf("%s-%s",faker.FirstName(),faker.LastName())	)
		}(i)
	}
	wg.Wait()
	fmt.Println("Finished for loop")
}

Error

Running for loop…
fatal error: concurrent map writes
Vernie-Thiel

goroutine 4 [running]:
runtime.throw({0x102820cb4?, 0x18?})
        /usr/local/go/src/runtime/panic.go:992 +0x50 fp=0x1400005bce0 sp=0x1400005bcb0 pc=0x1027749a0
runtime.mapassign_faststr(0x0?, 0x0?, {0x10281d2c7, 0xb})
        /usr/local/go/src/runtime/map_faststr.go:212 +0x3bc fp=0x1400005bd50 sp=0x1400005bce0 pc=0x1027558ac
github.com/go-faker/faker/v4.initMapperTagWithOption({0x0, 0x0, 0x0})
        /Users/hle/pkg/mod/github.com/go-faker/faker/v4@v4.0.0-beta.2/faker.go:220 +0x230 fp=0x1400005be60 sp=0x1400005bd50 pc=0x10280a2e0
github.com/go-faker/faker/v4.initOption({0x0, 0x0, 0x0})
        /Users/hle/pkg/mod/github.com/go-faker/faker/v4@v4.0.0-beta.2/faker.go:232 +0x40 fp=0x1400005be90 sp=0x1400005be60 pc=0x10280ab40
github.com/go-faker/faker/v4.singleFakeData({0x10281ccce, 0xa}, 0x1028749f0, {0x0?, 0x0?, 0x0?})
        /Users/hle/pkg/mod/github.com/go-faker/faker/v4@v4.0.0-beta.2/faker.go:1263 +0x3c fp=0x1400005bec0 sp=0x1400005be90 pc=0x10280b57c
github.com/go-faker/faker/v4.FirstName({0x0?, 0x0?, 0x0?})
        /Users/hle/pkg/mod/github.com/go-faker/faker/v4@v4.0.0-beta.2/person.go:227 +0x44 fp=0x1400005bf00 sp=0x1400005bec0 pc=0x10280d834
main.main.func1(0x0?)
        /Users/hle/src/github.com/huydinhle/tmp/go-playground/main.go:17 +0x5c fp=0x1400005bfb0 sp=0x1400005bf00 pc=0x102814d2c
main.main.func2()
        /Users/hle/src/github.com/huydinhle/tmp/go-playground/main.go:18 +0x34 fp=0x1400005bfd0 sp=0x1400005bfb0 pc=0x102814c94
runtime.goexit()
        /usr/local/go/src/runtime/asm_arm64.s:1263 +0x4 fp=0x1400005bfd0 sp=0x1400005bfd0 pc=0x1027a0c94
created by main.main
        /Users/hle/src/github.com/huydinhle/tmp/go-playground/main.go:15 +0x8c

goroutine 1 [runnable]:
main.main()
        /Users/hle/src/github.com/huydinhle/tmp/go-playground/main.go:15 +0xac
@bxcodec
Copy link
Contributor

bxcodec commented Sep 12, 2022

It will be fixed in the #6

@bxcodec
Copy link
Contributor

bxcodec commented Sep 19, 2022

@huydinhle can you try again with the new version v4.0.0-beta.3

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

Successfully merging a pull request may close this issue.

2 participants