Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Panic when using sessions #131

Closed
hsanjuan opened this issue May 24, 2019 · 2 comments · Fixed by ipfs/go-blockservice#28
Closed

Panic when using sessions #131

hsanjuan opened this issue May 24, 2019 · 2 comments · Fixed by ipfs/go-blockservice#28

Comments

@hsanjuan
Copy link
Contributor

This:

func TestSession(t *testing.T) {
	ctx := context.Background()
	p1, p2, closer := setupPeers(t)
	defer closer(t)

	m := map[string]string{
		"akey": "avalue",
	}

	codec := uint64(multihash.SHA2_256)
	node, err := cbor.WrapObject(m, codec, multihash.DefaultLengths[codec])
	if err != nil {
		t.Fatal(err)
	}

	t.Log("created node: ", node.Cid())
	err = p1.Add(ctx, node)
	if err != nil {
		t.Fatal(err)
	}

	sesGetter := p2.Session(ctx)
	_, err = sesGetter.Get(ctx, node.Cid())
	if err != nil {
		t.Fatal(err)
	}
}

results in:

--- FAIL: TestSession (0.63s)
    ipfs_test.go:151: created node:  bafyreigzkampgfuhmld36ljrywwcxogf5zyjbkasehbggbmgpy5tmrygpe
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4ee586]

goroutine 597 [running]:
testing.tRunner.func1(0xc0003a5e00)
        /usr/lib64/go/1.12/src/testing/testing.go:830 +0x392
panic(0xbbefc0, 0x150a8c0)
        /usr/lib64/go/1.12/src/runtime/panic.go:522 +0x1b5
context.propagateCancel(0x0, 0x0, 0xed0760, 0xc000372b80)
        /usr/lib64/go/1.12/src/context/context.go:242 +0x26
context.WithCancel(0x0, 0x0, 0x7, 0x2a, 0x0)
        /usr/lib64/go/1.12/src/context/context.go:231 +0x9c
github.com/ipfs/go-bitswap/sessionmanager.(*SessionManager).NewSession(0xc00065a180, 0x0, 0x0, 0x0, 0xc0005e3ce8)
        /home/hector/go/pkg/mod/github.com/ipfs/go-bitswap@v0.0.9/sessionmanager/sessionmanager.go:69 +0x6b
github.com/ipfs/go-bitswap.(*Bitswap).NewSession(0xc0000c5970, 0x0, 0x0, 0x40452f, 0xc0005e3d50)
        /home/hector/go/pkg/mod/github.com/ipfs/go-bitswap@v0.0.9/bitswap.go:401 +0x46
github.com/ipfs/go-blockservice.(*Session).getSession(0xc00036eaa0, 0x0, 0x0)
        /home/hector/go/pkg/mod/github.com/ipfs/go-blockservice@v0.0.6/blockservice.go:337 +0xbe
github.com/ipfs/go-blockservice.getBlock(0xedb4c0, 0xc0000ac010, 0xc000456450, 0x24, 0xee2360, 0xc0003131a0, 0xc0005e3e50, 0xc0000100f0, 0xc0005e3e78, 0x8de929, ...)
        /home/hector/go/pkg/mod/github.com/ipfs/go-blockservice@v0.0.6/blockservice.go:224 +0x209
github.com/ipfs/go-blockservice.(*Session).GetBlock(0xc00036eaa0, 0xedb4c0, 0xc0000ac010, 0xc000456450, 0x24, 0xc0004b4aa0, 0x7f924dc83f50, 0xc0004b4aa0, 0xc0003a5e01)
        /home/hector/go/pkg/mod/github.com/ipfs/go-blockservice@v0.0.6/blockservice.go:345 +0x92
github.com/ipfs/go-merkledag.(*sesGetter).Get(0xc0000100f0, 0xedb4c0, 0xc0000ac010, 0xc000456450, 0x24, 0x0, 0x0, 0xc0000b27c0, 0x29)
        /home/hector/go/pkg/mod/github.com/ipfs/go-merkledag@v0.0.3/merkledag.go:136 +0x66
github.com/hsanjuan/ipfs-lite.TestSession(0xc0003a5e00)
        /home/hector/go/src/github.com/hsanjuan/ipfs-lite/ipfs_test.go:158 +0x361
testing.tRunner(0xc0003a5e00, 0xe00b40)
@hsanjuan
Copy link
Contributor Author

This seems to come from: ipfs/go-blockservice@4b230aa

The s.sessCtx field is never set and a nil object travels down the stack

Stebalien added a commit to ipfs/go-blockservice that referenced this issue May 24, 2019
@Stebalien
Copy link
Member

ipfs/go-blockservice#28

Jorropo pushed a commit to ipfs/go-libipfs-rapide that referenced this issue Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants