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

cmd/compile, cmd/cgo: cgo callback fails with MSAN when passing aggregate args with paddings #42820

cherrymui opened this issue Nov 25, 2020 · 2 comments


Copy link

@cherrymui cherrymui commented Nov 25, 2020

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

tip (e8de596)

Does this issue reproduce with the latest release?

No. This starts to happen since cgo callback changes (CL 258938).

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


What did you do?

Build the following program using MSAN, where it calls from C to Go passing a C struct with padding.


package main

// Test passing C struct to exported Go function.

#include <stdint.h>

typedef struct { uintptr_t x, y; char b; } T;

void CF(int x);
import "C"

//export F
func F(t C.T) { println(t.x, t.y, t.b) }

func main() {


#include <stdint.h>
#include <stdlib.h>

typedef struct { uintptr_t x, y; char b; } T;

extern void F(T);

void CF(int x) {
	T *t = malloc(sizeof(T));
	t->x = x;
	t->y = x;
	t->b = (char)x;

What did you expect to see?

Program runs okay, prints 0 0 0.

What did you see instead?

$ CC=clang go build -msan .
$ ./x
Uninitialized bytes in __msan_check_mem_is_initialized at offset 17 inside [0x7fff51f33f00, 24)
==893435==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x4f5368 in msancall /usr/local/google/home/cherryyz/src/go-tip/src/runtime/msan_amd64.s:78

SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/local/google/home/cherryyz/src/go-tip/src/runtime/msan_amd64.s:78 in msancall
@cherrymui cherrymui added this to the Go1.16 milestone Nov 25, 2020
@cherrymui cherrymui self-assigned this Nov 25, 2020
Copy link

@gopherbot gopherbot commented Nov 30, 2020

Change mentions this issue: cmd/compile, runtime: use __msan_memmove for moving data


Copy link

@aclements aclements commented Dec 1, 2020

Marking as a release blocker because this is a regression from 1.15.


@gopherbot gopherbot closed this in 07cba70 Dec 3, 2020
@golang golang locked and limited conversation to collaborators Dec 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants