Giter VIP home page Giter VIP logo

cgo.wchar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cgo.wchar's Issues

Windows: cgo exception

I get the following when running go test or use this library (eg. via go.hid) on Windows. I've tried various versions of libiconv-2.dll to no effect.

Would you have any idea as to what the issue might be?

C:\Users\Seon-Wook\Go\src\github.com\GeertJohan\cgo.wchar>go test
Exception 0xc0000005 0x0 0x876c5bd 0x5a00ac
PC=0x5a00ac
signal arrived during cgo execution

github.com/GeertJohan/cgo%2ewchar._C2func_iconv_open(0x2713c0, 0x272b98, 0x0, 0x0, 0x0)
    github.com/GeertJohan/cgo.wchar/_test/_obj_test/_cgo_gotypes.go:39 +0x4f
github.com/GeertJohan/cgo%2ewchar.convertGoStringToWcharString(0x52b5a8, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Users/Seon-Wook/Go/src/github.com/GeertJohan/cgo.wchar/convert.go:43 +0x15a
github.com/GeertJohan/cgo%2ewchar.FromGoString(0x52b5a8, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Users/Seon-Wook/Go/src/github.com/GeertJohan/cgo.wchar/wchar.go:47 +0x58
github.com/GeertJohan/cgo%2ewchar.TestStringConversion(0x202220c0)
        C:/Users/Seon-Wook/Go/src/github.com/GeertJohan/cgo.wchar/wchar_test.go:16 +0x86
testing.tRunner(0x202220c0, 0x5b1040)
        c:/go/src/testing/testing.go:447 +0xb1
created by testing.RunTests
        c:/go/src/testing/testing.go:555 +0x863

goroutine 1 [chan receive]:
testing.RunTests(0x54c2e0, 0x5b1040, 0x4, 0x4, 0x201f2001)
        c:/go/src/testing/testing.go:556 +0x89f
testing.(*M).Run(0x201e82d0, 0x5b9960)
        c:/go/src/testing/testing.go:485 +0x5e
main.main()
        github.com/GeertJohan/cgo.wchar/_test/_testmain.go:58 +0x177

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        c:/go/src/runtime/asm_386.s:2287 +0x1
eax     0x4d3240
ebx     0x201fbe14
ecx     0x5ba0c0
edx     0x201fbdd4
edi     0x22c
esi     0x5b22e0
ebp     0x5b2500
esp     0x18fe9c
eip     0x5a00ac
eflags  0x10206
cs      0x23
fs      0x53
gs      0x2b
exit status 2
FAIL    github.com/GeertJohan/cgo.wchar 0.316s

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

The new rules: https://golang.org/cmd/cgo/#hdr-Passing_pointers
causes a crash in convert.go line 150:

_, 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.

Cast issue on Linux ARM

When running on raspberry pi (linux arm) this will not cast.

./go.hid/hid.go:597: cannot convert ws.Pointer() (type *wchar.Wchar) to type *C.wchar_t

Panic when running 'go test' on cc4deff

Hi

Running 'go test' on masters tip presents me with the following error:

http://sillymon.ch/data/gotesterror.txt

I am running Go tip at

go version devel +6e10ddc0bbc2 Tue May 13 12:17:49 2014 -0700 + linux/amd64

The panic seems to occur in the Go runtime at runtime/mcentral.c because of an empty memory list (the cause seems to be the runeCString := C.CString(string(r)) line in convert.go:184). Can you see anything obviously wrong?

Interestingly enough, after applying the following patch

diff --git a/convert.go b/convert.go
index e669ba9..97e9974 100644
--- a/convert.go
+++ b/convert.go
@@ -173,7 +173,7 @@ func convertGoRuneToWchar(r rune) (output Wchar, err error) {

        // bufferSizes for C
        bytesLeftInCSize := C.size_t(4)
-       bytesLeftOutCSize := C.size_t(4 * 4)
+       bytesLeftOutCSize := C.size_t(4)
        // TODO/FIXME: the last 4 bytes as indicated by bytesLeftOutCSize wont be used...
        // iconv assumes each given char to be one wchar.
        // in this case we know that the given 4 chars will actually be one unicode-point and therefore will result in one wchar.

the tests run (no panic occurs) but iconv(3) sets errno to E2BIG which indicates that the output buffer is too small. This seems odd to me because according to the iconv(3) man page both sizes are in bytes and since a Golang rune is encoded in UTF-8 (and will only contain one Unicode code point) both sizes should never have to be bigger than 4 bytes when converting one rune. I hit this 'go test' issue when I was trying to correct the output buffer size issue.

I also do not know why changing the value of the bytesLeftOutCSize function parameter would result in the C.CString copy suddenly working... any ideas?

LICENSE?

Hi,

Could you please add license information?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.