Thanks Jason! After more head banging in trying to narrow things down and 
taking yet another look through the existing issue reports you linked to I 
was able to find the fix. 

We were using a struct which had a field with type `strings.Builder`. The 
strings.Builder 
docs <https://pkg.go.dev/strings#Builder> state `Do not copy a non-zero 
Builder` as explained in this comment: golang/go#47276 (comment) 
<https://github.com/golang/go/issues/47276#issuecomment-882598415>. 
Switching to a string fixed the issue.

While the strings.Builder field was never non-zero in our use case, there 
might have been some race condition of sorts where it could become non-zero 
by the time the garbage collector was invoked since it was not always 
crashing right away.

*Take Away:* It would be great of the linters could warn about this, or if 
there could be a better error messages around this.

On Friday, July 19, 2024 at 6:56:37 PM UTC-7 Jason E. Aten wrote:

> There are a number of open bugs that mention the same error that you are 
> seeing
>
>
> https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+fatal+error%3A+found+bad+pointer+in+Go+heap+%28incorrect+use+of+unsafe+or+cgo%3F%29
>
> So you could try seeing if the issue reproduces with a different go 
> version, say, go 1.19. (per https://github.com/golang/go/issues/64781 )
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/76cb70f3-a6d5-4210-ac74-b546bfb98ca8n%40googlegroups.com.

Reply via email to