-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
pkg/proc: pad variable mem in extractVarInfoFromEntry #3365
Conversation
On 64 bit system, the byte size of the following struct is 16: type myStruct struct { a int b uint32 } But extractVarInfoFromEntry only allocates a mem of 12 bytes for it. When calling method of this struct with the "call" command, it will result in this error: write out of bounds This patch extends the mem by adding padding bytes to the end of the mem. Fixes go-delve#3364.
pkg/proc/variables.go
Outdated
@@ -1207,6 +1207,11 @@ func extractVarInfoFromEntry(tgt *Target, bi *BinaryInfo, image *Image, regs op. | |||
} | |||
} | |||
if cmem != nil { | |||
paddingBytes := int(t.Common().ByteSize) - len(cmem.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be moved inside newCompositeMemory in pkg/proc/mem.go (add an extra size int
parameter to it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Alessandro! I have moved the padding logic to newCompositeMemory
. Since the type of CommonType.ByteSize
is int64
, I add the extra parameter as size int64
. Please take another look.
LGTM, thank you! |
Thank you! Should I do a force push to squash the two commits into one? |
No need. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
On 64 bit system, the byte size of the following struct is 16:
But
extractVarInfoFromEntry
only allocates a mem of 12 bytes for it. When calling method of this struct with thecall
command, it will result in this error:This patch extends the mem by adding padding bytes to the end of the mem.
Fixes #3364.