GeertJohan / GeertJohan/cgo.wchar

Go 1.6 - C pointer <-> Go pointer rules change causes crash

Open
#10 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
14
Forks
9
PR merge metrics
No merged PRs in 30d

Description

The new rules: https://golang.org/cmd/cgo/#hdr-Passing_pointers
causes a crash in [convert.go line 150](https://github.com/GeertJohan/cgo.wchar/blob/master/convert.go#L150):

```
_, errno = C.iconv(iconv, &inputAsCCharsPtr, &bytesLeftInCSize, &outputCharsPtr, &bytesLeftOutCSize)
```

With the trace:

```
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 3 [running]:
panic(0x437c780, 0xc82000a1c0)
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
github.com/GeertJohan/cgo%2ewchar.convertWcharStringToGoString(0xc8200e4100, 0x12, 0x20, 0x0, 0x0, 0x0, 0x0)
/Users/stant/Documents/hackerloop/rotonde/src/github.com/GeertJohan/cgo.wchar/convert.go:150 +0x521
github.com/GeertJohan/cgo%2ewchar.WcharStringPtrToGoString(0x53059f0, 0x0, 0x0, 0x0, 0x0)
/Users/stant/Documents/hackerloop/rotonde/src/github.com/GeertJohan/cgo.wchar/wchar.go:141 +0x91
github.com/GeertJohan/go%2ehid.Enumerate(0x42, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/stant/Documents/hackerloop/rotonde/src/github.com/GeertJohan/go.hid/hid.go:205 +0x35f
main.StartHID.func2(0xc820010140, 0xc820010160, 0xc820010180, 0xc82006e1e0)

[...]

```

There must be other places in the code causing this crash.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at convert.go line 150, then read the caller in wchar.go at line 141 and reproduce the Go 1.6 cgo pointer panic. Inspect the package's other cgo calls for the same issue; the work is done when the reported conversion path and any matching calls no longer trigger this crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.