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

x/text: Case.Title panics on certain inputs. #55032

Closed
joeblubaugh opened this issue Sep 13, 2022 · 3 comments
Closed

x/text: Case.Title panics on certain inputs. #55032

joeblubaugh opened this issue Sep 13, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@joeblubaugh
Copy link

What version of Go are you using (go version)?

$ go version
1.17.9

Does this issue reproduce with the latest release?

Cannot confirm yet - we've only seen this in production systems with private user configuration.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

The Prometheus Alertmanager uses x/text/case's title casing when examining headers in email notifier configurations. When some strings are fed to x/case it panics.

Panics have happened with private customer configuration that we are unable to access. We're still trying to find reproducable strings using the fuzzer, but nothing yet.

What did you expect to see?

An error returned for strings that cannot be title-cased.

What did you see instead?

The program panics with this stack trace:

/vendor/gopkg.in/yaml.v2/decode.go:270 +0xa7
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler(0xc20be3f980, 0xc20c116e70, {0x7f170dda42b8, 0xc0430126c0})
/vendor/github.com/prometheus/alertmanager/config/notifiers.go:196 +0x1b9
github.com/prometheus/alertmanager/config.(*EmailConfig).UnmarshalYAML(0xc0430126c0, 0x2340b20?)
	/vendor/golang.org/x/text/cases/cases.go:51
golang.org/x/text/cases.Caser.String(...)
	/vendor/golang.org/x/text/transform/transform.go:650 +0xbe5
golang.org/x/text/transform.String({0x7f170e30ea18, 0xc0002d2a00}, {0xc20fd3aeb8, 0x2})
...
runtime error: slice bounds out of range [11:7]

the panic itself happens inside x/text/transform:

n := copy(src, s[pSrc:])

There is additional context on this issue for the Prometheus Alertmanager

@gopherbot gopherbot added this to the Unreleased milestone Sep 13, 2022
@mengzhuo mengzhuo added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 13, 2022
@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 13, 2022
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@dx034
Copy link

dx034 commented Feb 28, 2023

To anyone else encountering this issue: I had the exact same problem and it was caused by sharing the caser between goroutines. Creating a caser for each goroutine solved the issue.

@joeblubaugh
Copy link
Author

joeblubaugh commented Mar 1, 2023

It seems that only cases.Fold is documented as thread safe: https://pkg.go.dev/golang.org/x/text/cases#Fold, the others have internal state and should not be shared.

@golang golang locked and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants