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

fatal error: concurrent map read and map write #7

Open
kingname opened this issue Sep 6, 2021 · 2 comments
Open

fatal error: concurrent map read and map write #7

kingname opened this issue Sep 6, 2021 · 2 comments

Comments

@kingname
Copy link

kingname commented Sep 6, 2021

When I use goroutine, this line panic:

tr, _ := ja3transport.NewTransportWithConfig(browser.Ja3, &config)

the error msg is:

fatal error: concurrent map read and map write

goroutine 21 [running]:
runtime.throw(0x1358b57, 0x21)
        /usr/local/Cellar/go/1.16.3/libexec/src/runtime/panic.go:1117 +0x72 fp=0xc00004ec20 sp=0xc00004ebf0 pc=0x1036c92
runtime.mapaccess2_faststr(0x12fd980, 0xc00009ac90, 0xc0000ac979, 0x2, 0xc000080e18, 0xc000060101)
        /usr/local/Cellar/go/1.16.3/libexec/src/runtime/map_faststr.go:116 +0x4a5 fp=0xc00004ec90 sp=0xc00004ec20 pc=0x1015465
github.com/CUCyber/ja3transport.stringToSpec(0xc0000ac840, 0x153, 0x100f4b8, 0x170, 0x13497c0)
        /Users/kingname/go/pkg/mod/github.com/!c!u!cyber/[email protected]/transport.go:152 +0x4db fp=0xc00004ee08 sp=0xc00004ec90 pc=0x12c897b
github.com/CUCyber/ja3transport.NewTransportWithConfig(0xc0000ac840, 0x153, 0xc000001680, 0x0, 0x0, 0x0)
        /Users/kingname/go/pkg/mod/github.com/!c!u!cyber/[email protected]/transport.go:85 +0x39 fp=0xc00004ee50 sp=0xc00004ee08 pc=0x12c8399

it seems that there is a concurrent write on map at line 152 at transport.go:

image

The key reason is the global variable extMap:

image

@t94j0
Copy link
Collaborator

t94j0 commented Sep 6, 2021

Good find. Moving extMap into the specToString function will be the quickest way to fix this issue.

@reneManqueros
Copy link

Sent a PR for this: #16

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

3 participants