Skip to content

cmd/cgo: limit of C.CBytes #53965

@cuiweixie

Description

@cuiweixie

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

$ go version
go version go1.15.6 windows/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GOROOT/bin/go version: go version go1.15.6 windows/amd64
GOROOT/bin/go tool compile -V: compile version go1.15.6
gdb --version: GNU gdb (GDB) 8.1

What did you do?

package main

/*
#include <stdio.h>
void cprint(char * s) {
	printf("char %c\n", s[1024*1024*1024-1]);
	printf("char %c\n", s[1024*1024*1024]);
}
*/
import "C"

func main() {
	bs := make([]byte, 1<<30+10)
	bs[1024*1024*1024-1] = 'a'
	bs[1024*1024*1024] = 'b'
	t := C.CBytes(bs)
	C.cprint((*C.char)(t))
}

What did you expect to see?

char a
char b

What did you see instead?

char a
char

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions