summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mgc0.c3
-rw-r--r--src/runtime/syscall_windows.go10
-rw-r--r--src/runtime/syscall_windows_test.go8
3 files changed, 17 insertions, 4 deletions
diff --git a/src/runtime/mgc0.c b/src/runtime/mgc0.c
index 7754bad89..083beec22 100644
--- a/src/runtime/mgc0.c
+++ b/src/runtime/mgc0.c
@@ -350,6 +350,9 @@ scanblock(byte *b, uintptr n, byte *ptrmask)
x -= (uintptr)arena_start>>PageShift;
s = runtime·mheap.spans[x];
if(s == nil || k < s->start || obj >= s->limit || s->state != MSpanInUse) {
+ // Sometimes 32-bit heaps have holes. See issue 9872
+ if(PtrSize == 4 && s == nil)
+ continue;
// Stack pointers lie within the arena bounds but are not part of the GC heap.
// Ignore them.
if(s != nil && s->state == MSpanStack)
diff --git a/src/runtime/syscall_windows.go b/src/runtime/syscall_windows.go
index 5b76ad573..51004b78a 100644
--- a/src/runtime/syscall_windows.go
+++ b/src/runtime/syscall_windows.go
@@ -54,11 +54,13 @@ func compileCallback(fn eface, cleanstack bool) (code uintptr) {
panic("compilecallback: output parameter size is wrong")
}
argsize := uintptr(0)
- for _, t := range (*[1024](*_type))(unsafe.Pointer(&ft.in[0]))[:len(ft.in)] {
- if (*t).size > uintptrSize {
- panic("compilecallback: input parameter size is wrong")
+ if len(ft.in) > 0 {
+ for _, t := range (*[1024](*_type))(unsafe.Pointer(&ft.in[0]))[:len(ft.in)] {
+ if (*t).size > uintptrSize {
+ panic("compilecallback: input parameter size is wrong")
+ }
+ argsize += uintptrSize
}
- argsize += uintptrSize
}
lock(&cbs.lock)
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index ce8a9ec1b..126bef62e 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -533,3 +533,11 @@ func main() {
println(z)
}
`
+
+func TestCallbackWithNoInputParameters(t *testing.T) {
+ // Test that NewCallback and NewCallbackCDecl can accept functions without
+ // input parameters, see issue 9871.
+ cb := func() uintptr { return 0 }
+ _ = syscall.NewCallback(cb)
+ _ = syscall.NewCallbackCDecl(cb)
+}