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 read and write #188

Closed
bryanl opened this issue Aug 29, 2022 · 3 comments
Closed

Concurrent map read and write #188

bryanl opened this issue Aug 29, 2022 · 3 comments

Comments

@bryanl
Copy link

bryanl commented Aug 29, 2022

github.com/itchyny/gojq.funcIndex2({0x0?, 0x0?}, {0x1b3b040?, 0xc0008208d0?}, {0x1af5900?, 0xc00068fbf0?})
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/func.go:885 +0x2bc
github.com/itchyny/gojq.(*env).Next(0xc0004f8dc0)
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/execute.go:163 +0x1bff

Got this calling iter.Next()

@itchyny
Copy link
Owner

itchyny commented Aug 29, 2022

Please provide description with reproducible code and full stack traces.

@bryanl
Copy link
Author

bryanl commented Aug 29, 2022

I found another gojq goroutine running

github.com/itchyny/gojq.normalizeNumbers({0x1b3b180?, 0xc00083bad0?})
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/normalize.go:77 +0x105
github.com/itchyny/gojq.normalizeNumbers({0x1b3b180?, 0xc00083bd10?})
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/normalize.go:78 +0x6f1
github.com/itchyny/gojq.(*Code).RunWithContext(0xc0001b2fa0, {0x1e108f0?, 0xc000208000}, {0x1b3b180, 0xc00083bd10}, {0x0, 0x0, 0x0})
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/compiler.go:51 +0x34f
github.com/itchyny/gojq.(*Code).Run(...)
        /Users/bryan/go/pkg/mod/github.com/itchyny/gojq@v0.12.8/compiler.go:38

Starting with line 884 in func.go

case map[string]interface{}:
    return v[x]

Starting with line 76 in normalize.go

case map[string]interface{}:
	for k, x := range v {
		v[k] = normalizeNumbers(x)
	}
	return v

Looks like the code is reading a map that can also be written to at the same time.

@itchyny
Copy link
Owner

itchyny commented Aug 29, 2022

You should not run a gojq query with the same input value.

@itchyny itchyny closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2022
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