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

Windows purego errors #410

Closed
wizzymore opened this issue Sep 3, 2024 · 3 comments
Closed

Windows purego errors #410

wizzymore opened this issue Sep 3, 2024 · 3 comments

Comments

@wizzymore
Copy link

I am using the release of raylib from: Nov 18, 2023, i tried with both x64 versions they do the same thing.
I also tried to build the app and it works, the build is ok this error appears only in the runtime.

> go run .
panic: purego: struct return values only supported on darwin arm64 & amd64

goroutine 1 [running, locked to thread]:
github.com/ebitengine/purego.RegisterFunc({0x1bf9c0?, 0xd1adf0?}, 0x7ff97085a8f0)        
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/func.go:169 +0x365
github.com/ebitengine/purego.RegisterLibFunc({0x1bf9c0, 0xd1adf0}, 0xc00011de10?, {0x1edd4b?, 0x1a872f?})
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/func.go:25 +0x45
github.com/gen2brain/raylib-go/raylib.init.1()
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/gen2brain/raylib-go/raylib@v0.0.0-20240418150228-9548fadb54e6/raylib_purego.go:730 +0x203d
exit status 2
@JupiterRider
Copy link
Contributor

Hey @wizzymore,
if you use the raylib-go version from Nov 18, 2023 (tag: raylib/v5.0.0), you also have to use purego v0.5.0:
https://github.com/gen2brain/raylib-go/blob/raylib/v5.0.0/raylib/go.mod#L6

purego has a runtime check in v0.7.1, which doesn't allow you to use structs.

For raylib-go (at least for the purego version) I recommend you to use the latest version (v0.0.0-20240826113553-b4d0c52dc927), because we fixed many bugs since then.

@wizzymore
Copy link
Author

Thanks, just updating the package seems to fix most of the issues i had, still i have pure-go 0.7.1, i don't know how to use another version as installing 0.5.0 uninstalls raylib-go

The only bug that i found, surprisingly not in shaders or other more complicated logic, it was with ColorFromNormalized function:

Let me know if you want me to create another issue for this error, i will close this one, thanks again.

Exception 0xc0000005 0x0 0xffffffffffffffff 0x7ff94d50af70
PC=0x7ff94d50af70

runtime.cgocall(0x81ebc0, 0x13df728)
        C:/Program Files/Go/src/runtime/cgocall.go:167 +0x3e fp=0xc00011d358 sp=0xc00011d2f0 pc=0x81107e
syscall.SyscallN(0x0?, {0xc00011d398?, 0xc000038508?, 0x7f7929?})
        C:/Program Files/Go/src/runtime/syscall_windows.go:519 +0x46 fp=0xc00011d378 sp=0xc00011d358 pc=0x819206
syscall.Syscall15(0x0?, 0xc00011d520?, 0x8484cd?, 0x883400?, 0xc00008c188?, 0x1?, 0x810ceb?, 0x0?, 0x0?, 0x0, ...)
        C:/Program Files/Go/src/runtime/syscall_windows.go:486 +0x10b fp=0xc00011d498 sp=0xc00011d378 pc=0x81918b
github.com/ebitengine/purego.syscall_syscall15X(0xc00011d5a0?, 0x810b58?, 0xc00011d5a0?, 0x7b460d?, 0x0?, 0x0?, 0x0?, 0xc00011d5d8?, 0x8125a2?, 0x0, ...)
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/syscall_windows.go:22 +0x98 fp=0xc00011d530 sp=0xc00011d498 pc=0x868618
github.com/ebitengine/purego.RegisterFunc.func1({0xc00008a1f8?, 0x1?, 0x1?})
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/func.go:305 +0xa66 fp=0xc00011d920 sp=0xc00011d530 pc=0x8667e6
reflect.callReflect(0xc00014f380, 0xc00011dde0, 0xc00011dcb8, 0xc00011dcc0)
        C:/Program Files/Go/src/reflect/value.go:767 +0x53d fp=0xc00011dc68 sp=0xc00011d920 pc=0x84367d
reflect.callReflect(0xc00014f380, 0xc00011dde0, 0xc00011dcb8, 0xc00011dcc0)
        <autogenerated>:1 +0x4a fp=0xc00011dc98 sp=0xc00011dc68 pc=0x848baa
reflect.makeFuncStub()
        C:/Program Files/Go/src/reflect/asm_amd64.s:47 +0x73 fp=0xc00011dde0 sp=0xc00011dc98 pc=0x8485d3
github.com/gen2brain/raylib-go/raylib.ColorFromNormalized(...)
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/gen2brain/raylib-go/raylib@v0.0.0-20240826113553-b4d0c52dc927/raylib_purego.go:2783
main.(*TitleScene).Draw(0xc00008e000)
        H:/src/GameProgramming/TheLastRoomGo/titlescene.go:131 +0x22f fp=0xc00011dec0 sp=0xc00011dde0 pc=0x870e4f
main.(*Game).Draw(...)
        H:/src/GameProgramming/TheLastRoomGo/main.go:59
main.main()
        H:/src/GameProgramming/TheLastRoomGo/main.go:111 +0x1d9 fp=0xc00011df50 sp=0xc00011dec0 pc=0x86fbf9
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:272 +0x27d fp=0xc00011dfe0 sp=0xc00011df50 pc=0x7e775d
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00011dfe8 sp=0xc00011dfe0 pc=0x81d441

goroutine 2 gp=0xc000060700 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000063fa8 sp=0xc000063f88 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:337 +0xb8 fp=0xc000063fe0 sp=0xc000063fa8 pc=0x7e7a78
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x81d441
created by runtime.init.7 in goroutine 1
        C:/Program Files/Go/src/runtime/proc.go:325 +0x1a

goroutine 3 gp=0xc000060a80 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000065f80 sp=0xc000065f60 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.bgsweep(0xc00001c080)
        C:/Program Files/Go/src/runtime/mgcsweep.go:277 +0x94 fp=0xc000065fc8 sp=0xc000065f80 pc=0x7d1714
runtime.gcenable.gowrap1()
        C:/Program Files/Go/src/runtime/mgc.go:203 +0x25 fp=0xc000065fe0 sp=0xc000065fc8 pc=0x7c5de5
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000065fe8 sp=0xc000065fe0 pc=0x81d441
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:203 +0x66

goroutine 4 gp=0xc000060c40 m=nil [GC scavenge wait]:
runtime.gopark(0xc00001c080?, 0x8d8458?, 0x1?, 0x0?, 0xc000060c40?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000077f78 sp=0xc000077f58 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.(*scavengerState).park(0x13de660)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc000077fa8 sp=0xc000077f78 pc=0x7cf149
runtime.bgscavenge(0xc00001c080)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc000077fc8 sp=0xc000077fa8 pc=0x7cf6bc
runtime.gcenable.gowrap2()
        C:/Program Files/Go/src/runtime/mgc.go:204 +0x25 fp=0xc000077fe0 sp=0xc000077fc8 pc=0x7c5d85
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000077fe8 sp=0xc000077fe0 pc=0x81d441
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:204 +0xa5

goroutine 5 gp=0xc000060fc0 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000079e20 sp=0xc000079e00 pc=0x815c6e
runtime.runfinq()
        C:/Program Files/Go/src/runtime/mfinal.go:193 +0x107 fp=0xc000079fe0 sp=0xc000079e20 pc=0x7c4ea7
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000079fe8 sp=0xc000079fe0 pc=0x81d441
created by runtime.createfing in goroutine 1
        C:/Program Files/Go/src/runtime/mfinal.go:163 +0x3d

goroutine 6 gp=0xc000061180 m=nil [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000073f18 sp=0xc000073ef8 pc=0x815c6e
runtime.chanrecv(0xc00001e150, 0x0, 0x1)
        C:/Program Files/Go/src/runtime/chan.go:639 +0x41e fp=0xc000073f90 sp=0xc000073f18 pc=0x7b687e
runtime.chanrecv1(0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/chan.go:489 +0x12 fp=0xc000073fb8 sp=0xc000073f90 pc=0x7b6452
runtime.unique_runtime_registerUniqueMapCleanup.func1(...)
        C:/Program Files/Go/src/runtime/mgc.go:1732
runtime.unique_runtime_registerUniqueMapCleanup.gowrap1()
        C:/Program Files/Go/src/runtime/mgc.go:1735 +0x2f fp=0xc000073fe0 sp=0xc000073fb8 pc=0x7c8e8f
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000073fe8 sp=0xc000073fe0 pc=0x81d441
created by unique.runtime_registerUniqueMapCleanup in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:1730 +0x96
rax     0x7ff94d50af70
rbx     0x13df728
rcx     0x3f8000003f800000
rdx     0x0
rdi     0xbc88fff6e8
rsi     0xbc88fff670
rbp     0xbc88fff7d0
rsp     0xbc88fff668
r8      0x0
r9      0x0
r10     0x0
r11     0x0
r12     0xc00011d518
r13     0x0
r14     0xc000060000
r15     0x0
rip     0x7ff94d50af70
rflags  0x10283
cs      0x33
fs      0x53
gs      0x2b
exit status 2

@JupiterRider
Copy link
Contributor

The only bug that i found, surprisingly not in shaders or other more complicated logic, it was with ColorFromNormalized function:

Let me know if you want me to create another issue for this error, i will close this one, thanks again.

Exception 0xc0000005 0x0 0xffffffffffffffff 0x7ff94d50af70
PC=0x7ff94d50af70

runtime.cgocall(0x81ebc0, 0x13df728)
        C:/Program Files/Go/src/runtime/cgocall.go:167 +0x3e fp=0xc00011d358 sp=0xc00011d2f0 pc=0x81107e
syscall.SyscallN(0x0?, {0xc00011d398?, 0xc000038508?, 0x7f7929?})
        C:/Program Files/Go/src/runtime/syscall_windows.go:519 +0x46 fp=0xc00011d378 sp=0xc00011d358 pc=0x819206
syscall.Syscall15(0x0?, 0xc00011d520?, 0x8484cd?, 0x883400?, 0xc00008c188?, 0x1?, 0x810ceb?, 0x0?, 0x0?, 0x0, ...)
        C:/Program Files/Go/src/runtime/syscall_windows.go:486 +0x10b fp=0xc00011d498 sp=0xc00011d378 pc=0x81918b
github.com/ebitengine/purego.syscall_syscall15X(0xc00011d5a0?, 0x810b58?, 0xc00011d5a0?, 0x7b460d?, 0x0?, 0x0?, 0x0?, 0xc00011d5d8?, 0x8125a2?, 0x0, ...)
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/syscall_windows.go:22 +0x98 fp=0xc00011d530 sp=0xc00011d498 pc=0x868618
github.com/ebitengine/purego.RegisterFunc.func1({0xc00008a1f8?, 0x1?, 0x1?})
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/ebitengine/purego@v0.7.1/func.go:305 +0xa66 fp=0xc00011d920 sp=0xc00011d530 pc=0x8667e6
reflect.callReflect(0xc00014f380, 0xc00011dde0, 0xc00011dcb8, 0xc00011dcc0)
        C:/Program Files/Go/src/reflect/value.go:767 +0x53d fp=0xc00011dc68 sp=0xc00011d920 pc=0x84367d
reflect.callReflect(0xc00014f380, 0xc00011dde0, 0xc00011dcb8, 0xc00011dcc0)
        <autogenerated>:1 +0x4a fp=0xc00011dc98 sp=0xc00011dc68 pc=0x848baa
reflect.makeFuncStub()
        C:/Program Files/Go/src/reflect/asm_amd64.s:47 +0x73 fp=0xc00011dde0 sp=0xc00011dc98 pc=0x8485d3
github.com/gen2brain/raylib-go/raylib.ColorFromNormalized(...)
        C:/Users/Cristian Bilu/go/pkg/mod/github.com/gen2brain/raylib-go/raylib@v0.0.0-20240826113553-b4d0c52dc927/raylib_purego.go:2783
main.(*TitleScene).Draw(0xc00008e000)
        H:/src/GameProgramming/TheLastRoomGo/titlescene.go:131 +0x22f fp=0xc00011dec0 sp=0xc00011dde0 pc=0x870e4f
main.(*Game).Draw(...)
        H:/src/GameProgramming/TheLastRoomGo/main.go:59
main.main()
        H:/src/GameProgramming/TheLastRoomGo/main.go:111 +0x1d9 fp=0xc00011df50 sp=0xc00011dec0 pc=0x86fbf9
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:272 +0x27d fp=0xc00011dfe0 sp=0xc00011df50 pc=0x7e775d
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00011dfe8 sp=0xc00011dfe0 pc=0x81d441

goroutine 2 gp=0xc000060700 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000063fa8 sp=0xc000063f88 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:337 +0xb8 fp=0xc000063fe0 sp=0xc000063fa8 pc=0x7e7a78
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x81d441
created by runtime.init.7 in goroutine 1
        C:/Program Files/Go/src/runtime/proc.go:325 +0x1a

goroutine 3 gp=0xc000060a80 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000065f80 sp=0xc000065f60 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.bgsweep(0xc00001c080)
        C:/Program Files/Go/src/runtime/mgcsweep.go:277 +0x94 fp=0xc000065fc8 sp=0xc000065f80 pc=0x7d1714
runtime.gcenable.gowrap1()
        C:/Program Files/Go/src/runtime/mgc.go:203 +0x25 fp=0xc000065fe0 sp=0xc000065fc8 pc=0x7c5de5
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000065fe8 sp=0xc000065fe0 pc=0x81d441
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:203 +0x66

goroutine 4 gp=0xc000060c40 m=nil [GC scavenge wait]:
runtime.gopark(0xc00001c080?, 0x8d8458?, 0x1?, 0x0?, 0xc000060c40?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000077f78 sp=0xc000077f58 pc=0x815c6e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:430
runtime.(*scavengerState).park(0x13de660)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc000077fa8 sp=0xc000077f78 pc=0x7cf149
runtime.bgscavenge(0xc00001c080)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc000077fc8 sp=0xc000077fa8 pc=0x7cf6bc
runtime.gcenable.gowrap2()
        C:/Program Files/Go/src/runtime/mgc.go:204 +0x25 fp=0xc000077fe0 sp=0xc000077fc8 pc=0x7c5d85
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000077fe8 sp=0xc000077fe0 pc=0x81d441
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:204 +0xa5

goroutine 5 gp=0xc000060fc0 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000079e20 sp=0xc000079e00 pc=0x815c6e
runtime.runfinq()
        C:/Program Files/Go/src/runtime/mfinal.go:193 +0x107 fp=0xc000079fe0 sp=0xc000079e20 pc=0x7c4ea7
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000079fe8 sp=0xc000079fe0 pc=0x81d441
created by runtime.createfing in goroutine 1
        C:/Program Files/Go/src/runtime/mfinal.go:163 +0x3d

goroutine 6 gp=0xc000061180 m=nil [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:424 +0xce fp=0xc000073f18 sp=0xc000073ef8 pc=0x815c6e
runtime.chanrecv(0xc00001e150, 0x0, 0x1)
        C:/Program Files/Go/src/runtime/chan.go:639 +0x41e fp=0xc000073f90 sp=0xc000073f18 pc=0x7b687e
runtime.chanrecv1(0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/chan.go:489 +0x12 fp=0xc000073fb8 sp=0xc000073f90 pc=0x7b6452
runtime.unique_runtime_registerUniqueMapCleanup.func1(...)
        C:/Program Files/Go/src/runtime/mgc.go:1732
runtime.unique_runtime_registerUniqueMapCleanup.gowrap1()
        C:/Program Files/Go/src/runtime/mgc.go:1735 +0x2f fp=0xc000073fe0 sp=0xc000073fb8 pc=0x7c8e8f
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000073fe8 sp=0xc000073fe0 pc=0x81d441
created by unique.runtime_registerUniqueMapCleanup in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:1730 +0x96
rax     0x7ff94d50af70
rbx     0x13df728
rcx     0x3f8000003f800000
rdx     0x0
rdi     0xbc88fff6e8
rsi     0xbc88fff670
rbp     0xbc88fff7d0
rsp     0xbc88fff668
r8      0x0
r9      0x0
r10     0x0
r11     0x0
r12     0xc00011d518
r13     0x0
r14     0xc000060000
r15     0x0
rip     0x7ff94d50af70
rflags  0x10283
cs      0x33
fs      0x53
gs      0x2b
exit status 2

@wizzymore I created a PR to fix this #411
Thanks for finding this bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants