Skip to content

Issue panic when user interrupt signal #3002

Closed

Description

@ja7ad

When close with ctrl+c or user interrupt signal this panic happen on close channel.

panic: close of closed channel [recovered]
	panic: closure error: unexpected panic caught: close of closed channel
	
	Closure added at:
		runtime.main at runtime/proc.go:272
		runtime.goexit at runtime/asm_amd64.s:1700

goroutine 1 [running]:
	runtime/panic.go:785 +0x132
github.com/libp2p/go-libp2p/p2p/host/eventbus.(*sub).Close(0xc00027ef50)
	github.com/libp2p/go-libp2p@v0.36.5/p2p/host/eventbus/basic.go:189 +0x225
...
Version Information
v0.36.5

Activity

  1. MarcoPolo commented on Oct 9, 2024

    @MarcoPolo
    Collaborator

    Could you include more of the stack trace? The issue is that we're closing a subscription twice, but I can't tell from the stack trace/context which subscription is being closed twice. I'm also not able to reproduce this issue in my minimal setup.

    Could you share an example that reproduce the issue?

  2. ja7ad commented on Oct 9, 2024

    @ja7ad
    Author

    Could you include more of the stack trace? The issue is that we're closing a subscription twice, but I can't tell from the stack trace/context which subscription is being closed twice. I'm also not able to reproduce this issue in my minimal setup.

    Could you share an example that reproduce the issue?

    panic: close of closed channel [recovered]
    	panic: closure error: unexpected panic caught: close of closed channel
    	
    	Closure added at:
    		main.main at github.com/pactus-project/pactus/cmd/gtk/main.go:126
    		runtime.main at runtime/proc.go:272
    		runtime.goexit at runtime/asm_amd64.s:1700
    
    goroutine 1 [running]:
    github.com/gotk3/gotk3/internal/closure.FuncStack.Panicf({{0x1b14c80, 0xc00032e8a0, 0x13}, {0xc0004bedf8, 0x3, 0x3}}, {0x1f1c3db, 0x1b}, {0xc000db9080, 0x1, ...})
    	github.com/gotk3/gotk3@v0.6.2/internal/closure/funcstack.go:116 +0x91e
    github.com/gotk3/gotk3/internal/closure.FuncStack.TryRepanic({{0x1b14c80, 0xc00032e8a0, 0x13}, {0xc0004bedf8, 0x3, 0x3}})
    	github.com/gotk3/gotk3@v0.6.2/internal/closure/funcstack.go:134 +0x13c
    panic({0x1c09b20?, 0x2dd98d0?})
    	runtime/panic.go:785 +0x132
    github.com/libp2p/go-libp2p/p2p/host/eventbus.(*sub).Close(0xc00027ef50)
    	github.com/libp2p/go-libp2p@v0.36.5/p2p/host/eventbus/basic.go:189 +0x225
    github.com/pactus-project/pactus/network.(*NotifeeService).Stop(...)
    	github.com/pactus-project/pactus/network/notifee.go:91
    github.com/pactus-project/pactus/network.(*network).Stop(0xc00061a600)
    	github.com/pactus-project/pactus/network/network.go:355 +0xe2
    github.com/pactus-project/pactus/node.(*Node).Stop(0xc0000f4f30)
    	github.com/pactus-project/pactus/node/node.go:166 +0x46
    main.main.func3()
    	github.com/pactus-project/pactus/cmd/gtk/main.go:128 +0x8f
    reflect.Value.call({0x1b14c80?, 0xc00032e8a0?, 0x3b0000c0011805b0?}, {0x1ef64d6, 0x4}, {0x420d020, 0x0, 0x1beb600?})
    	reflect/value.go:581 +0xca6
    reflect.Value.Call({0x1b14c80?, 0xc00032e8a0?, 0x795834000f90?}, {0x420d020?, 0x1?, 0x10?})
    	reflect/value.go:365 +0xb9
    github.com/gotk3/gotk3/glib.goMarshal(0x3?, 0x0, 0x1, 0x795857dff750, 0xc0000061c0?, 0x79584425ea60?)
    	github.com/gotk3/gotk3@v0.6.2/glib/glib.go:271 +0xa11
    github.com/gotk3/gotk3/glib._Cfunc_g_application_run(0x4bf9560, 0x0, 0x795844000e70)
    	_cgo_gotypes.go:1572 +0x4b
    github.com/gotk3/gotk3/glib.(*Application).Run.func4(0xc000000000?, {0x0?, 0x0, 0x4cd1c0?}, 0x795844000e70)
    	github.com/gotk3/gotk3@v0.6.2/glib/application.go:185 +0x74
    github.com/gotk3/gotk3/glib.(*Application).Run(0xc0004e9dd0, {0x0, 0x0, 0x0})
    	github.com/gotk3/gotk3@v0.6.2/glib/application.go:185 +0x17f
    main.main()
    	github.com/pactus-project/pactus/cmd/gtk/main.go:140 +0x358
    
  3. MarcoPolo commented on Oct 9, 2024

    @MarcoPolo
    Collaborator

    Are you sure you aren't calling pactus' Node.Stop twice? Do you only see a single "stopping Node" log?

  4. sukunrt commented on Nov 11, 2024

    @sukunrt
    Member

    It seems reasonable to not panic on closing subscription twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions