Commit 74f2fb0
committed
cmd/cgo: improve cgoCheckPointer error message
When an unpinned Go pointer is passed to a C function, this error shows up:
```
panic: runtime error: cgo argument has Go pointer to unpinned Go pointer
goroutine 1 [running]:
main.main.func1(...)
/mnt/go/src/test.go:15
main.main()
/mnt/go/src/test.go:15 +0x79
exit status 2
```
Retrieve the callee name, and use it in the error message.
```
panic: runtime error: cgo argument of function main.main.func1 has Go pointer to unpinned Go pointer
goroutine 1 [running]:
main.main.func1(...)
/mnt/go/src/test.go:15
main.main()
/mnt/go/src/test.go:15 +0x88
exit status 2
```
GH: #75856
Cc: Keith Randall <khr@golang.org>
Cc: Sean Liao <sean@liao.dev>
Cc: Ian Lance Taylor <iant@golang.org>1 parent af3d442 commit 74f2fb0
1 file changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| 538 | + | |
| 539 | + | |
538 | 540 | | |
539 | 541 | | |
540 | 542 | | |
541 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
542 | 555 | | |
543 | 556 | | |
544 | 557 | | |
| |||
591 | 604 | | |
592 | 605 | | |
593 | 606 | | |
594 | | - | |
595 | | - | |
596 | 607 | | |
597 | 608 | | |
598 | 609 | | |
| |||
0 commit comments