-
Notifications
You must be signed in to change notification settings - Fork 18k
when calling strings.Split, it panics. #39495
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
Comments
Please show us a small program that demonstrates the problem. Thanks. |
I suspect that it was caused by |
@ianlancetaylor @hantmac |
It's true that strings.Split should never panic. However, many many Go users are using strings.Split every day and not seeing panics. There is nothing obviously wrong with strings.Split. For us to debug this further, we need a specific piece of code that panics reliably. Otherwise there's really very little we can do. The crashing line in your stack trace is:
It is unclear why there is no stack frame for bytealg.IndexString itself. Something is very strange about your environment. |
Yes, it is true. |
Something strange is happening here. One of the strings on the stack has gone bad. If you look at the entry for
That first string is bad. It has a backing store pointer of I suspect clobbering of the stack from some unknown source. Hard to be sure. Running with |
I don't think cross-compiling would be a problem, unless you use cgo and your C cross-compiler setup is broken. Which seems unlikely - that would probably cause a crash long before this code could execute. |
@randall77 It seems hard to trace the root cause for now, and obviously not a reason of strings.Split itself. |
This looks like memory corruption. Have you tried running your program under the race detector? See https://blog.golang.org/race-detector . |
this can happen if a string is created from a []byte slice with some non utf-8 literals. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
We just call the func strings.Split() in our app.
What did you expect to see?
do not panic.
What did you see instead?
It panics. details as follows
dat.txt
The text was updated successfully, but these errors were encountered: