Skip to content

About fatal error when triggering gc #2

Description

@lynin

hello, I found a number of errors, which were seems concentrated in the gc of go runtime.

The following is a summary of the error messages:

1 =>
runtime: gp: gp=0xc00041e820, goid=347, gp->atomicstatus=1
runtime:  g:  g=0x1392220, goid=0,  g->atomicstatus=0
fatal error: bad g->status in ready

2 =>
fatal error: casgstatus: waiting for Gwaiting but is Grunnable

When I solved the above problems, the next fatal error came:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x330 pc=0x1038847]

The error stack is too long, so complete information is not provided here🤔

BTW, The tested go version is 1.19.2 and 1.19.3

Here is my test code:

package itogami_test

import (
	"github.com/alphadose/itogami"
	"runtime/debug"
	"sync"
	"testing"
)

func doing() {
	times := 1000
	size := 100
	task := func(i int) {
		_ = i + 1
	}

	pool := itogami.NewPoolWithFunc(uint64(size), task)

	var wg sync.WaitGroup
	wg.Add(size)

	for i := 0; i < size; i++ {
		go func() {
			for n := 0; n < times; n++ {
				pool.Invoke(n)
			}
			wg.Done()
		}()
	}
	wg.Wait()
}

func TestTriggerGC(t *testing.T) {
	debug.SetMemoryLimit((1 << 20) * 100) // 100m

	for i := 0; i < 100; i++ {
		doing()
	}
}

Hope to get your help, thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions