Skip to content

cmd/gc: Method values + slicing arrays + inlining == Broken strings #5753

Closed
@dominikh

Description

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Compile and run http://play.golang.org/p/Yl6EXET0fc (can reproduce on the playground
as well)
2. Notice how the length for the second string becomes ridiculously big
3.

What is the expected output?
Not breaking the string

What do you see instead?
Broken strings that will cause Go to read memory it shouldn't.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux

Which version are you using?  (run 'go version')
This happens both with Go 1.1 and current tip (go version devel +56909cb770fe Fri Jun 21
18:07:57 2013 -0700 linux/amd64)

Please provide any additional information below.

1) This only happens when using method values. Function values are fine
2) This only happens when manually creating the backing array
3) Disabling inlining avoids the issue.

(Reporting this on behalf of Mikhail Panchenko who initially discovered this issue in a
more complex scenario)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions