Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttachV2SessionToken multi-thread panic #323

Closed
KirillovDenis opened this issue Jul 5, 2021 · 1 comment
Closed

AttachV2SessionToken multi-thread panic #323

KirillovDenis opened this issue Jul 5, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@KirillovDenis
Copy link

Trying to get objects using the same sessionToken in multiple gorutines causes panic:

panic: runtime error: slice bounds out of range [36:35]

goroutine 572 [running]:
github.com/nspcc-dev/neofs-api-go/v2/refs.(*Address).StableMarshal(0xc000222e20, 0xc014d08068, 0x23, 0x4fff98, 0x8c065d, 0x2, 0xb7fcf8, 0xc000140960, 0x24)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/refs/marshal.go:164 +0x21e
github.com/nspcc-dev/neofs-api-go/util/proto.NestedStructureMarshal(0x2, 0xc014d08066, 0x25, 0x4fff9a, 0xb7fc08, 0xc000222e20, 0x0, 0x0, 0x2)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/util/proto/marshal.go:320 +0x23b
github.com/nspcc-dev/neofs-api-go/v2/session.(*ObjectSessionContext).StableMarshal(0xc018453090, 0xc014d08064, 0x27, 0x4fff9c, 0xc014d0803f, 0x4c, 0x4fffc1, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/session/marshal.go:277 +0xff
github.com/nspcc-dev/neofs-api-go/util/proto.NestedStructureMarshal(0x5, 0xc014d08062, 0x29, 0x4fff9e, 0xb80338, 0xc018453090, 0x30, 0x23, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/util/proto/marshal.go:320 +0x23b
github.com/nspcc-dev/neofs-api-go/v2/session.(*SessionTokenBody).StableMarshal(0xc0002800a0, 0xc014d0800e, 0x7d, 0x4ffff2, 0xb80338, 0xc018453090, 0x4e, 0x12, 0x54)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/session/marshal.go:409 +0x41f
github.com/nspcc-dev/neofs-api-go/util/proto.NestedStructureMarshal(0x1, 0xc014d0800b, 0x80, 0x4ffff5, 0xb805b8, 0xc0002800a0, 0x0, 0x0, 0xa5)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/util/proto/marshal.go:320 +0x23b
github.com/nspcc-dev/neofs-api-go/v2/session.(*SessionToken).StableMarshal(0xc018b94990, 0xc014d0800b, 0x80, 0x4ffff5, 0xc014d08002, 0x89, 0x4ffffe, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/session/marshal.go:473 +0x86
github.com/nspcc-dev/neofs-api-go/util/proto.NestedStructureMarshal(0x5, 0xc014d08008, 0x83, 0x4ffff8, 0xb80568, 0xc018b94990, 0x0, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/util/proto/marshal.go:320 +0x23b
github.com/nspcc-dev/neofs-api-go/v2/session.(*RequestMetaHeader).StableMarshal(0xc001ff3ea0, 0xc014d08000, 0x8b, 0x500000, 0x93f951, 0xf34500, 0x9c8ee0, 0xc018369da0, 0x8b)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/session/marshal.go:552 +0x351
github.com/nspcc-dev/neofs-api-go/v2/signature.stableMarshalerWrapper.StableMarshal(...)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/signature/sign.go:192
github.com/nspcc-dev/neofs-api-go/crypto/proto.SetDataSource.func1(0x7fd78810c338, 0x10, 0x10, 0x7fd7b31eafe8, 0x10)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/crypto/proto/sign.go:48 +0xa3
github.com/nspcc-dev/neofs-api-go/crypto.Sign(0xb7d980, 0xc0002a8510, 0xc018b97d00, 0xaebc78, 0xc018b94a00, 0x0, 0xc018b949f0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/crypto/sign.go:57 +0x2e
github.com/nspcc-dev/neofs-api-go/v2/crypto.Sign(0xb7d980, 0xc0002a8510, 0xb81440, 0xc018b949f0, 0xc018b93890, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/crypto/sign.go:55 +0x165
github.com/nspcc-dev/neofs-api-go/v2/signature.signServiceMessagePart(0xb7d980, 0xc0002a8510, 0xb803b0, 0xc001ff3ea0, 0xc00205fd10, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/signature/sign.go:213 +0xd5
github.com/nspcc-dev/neofs-api-go/v2/signature.SignServiceMessage(0xb7d980, 0xc0002a8510, 0xa75ba0, 0xc018369d40, 0x2, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/v2/signature/sign.go:160 +0x289
github.com/nspcc-dev/neofs-api-go/pkg/client.(*clientImpl).GetObject(0xc000159820, 0xb85f30, 0xc000124018, 0xc018b93740, 0xc0000c8a60, 0x1, 0x1, 0x0, 0x0, 0x0)
	/home/denis/go/pkg/mod/github.com/nspcc-dev/neofs-api-go@v1.28.1-0.20210701155341-1ffc60122adf/pkg/client/object.go:595 +0x367
github.com/nspcc-dev/test.TestName.func1(0xc0000430a0, 0xb8ce78, 0xc000159820, 0xc000140990, 0xc00025f2c0, 0xc000222e20)
	/home/denis/github/test/main_test.go:54 +0x4f6
created by github.com/nspcc-dev/test.TestName
	/home/denis/github/test/main_test.go:43 +0x40a

Environment

neofs-api-go v1.28.0, v1.28.1

Step to reproduce

  1. Create a public container with some object,
  2. Try to getObject, searchObject, listContainers using several gorutines:
address := object.NewAddress()
address.Parse("BSy3ntSKpVVxgDAJGU8ooGfdpgGQaFNZDC8sjhH2VhaZ/3vtxk1zwRthEHbmVeLjydrojtazKUe4scC9HCNMsbGcU")

key, _ := keys.NewPrivateKey()
wallet2, _ := owner.NEO3WalletFromECDSAPublicKey((ecdsa.PublicKey)(*key.PublicKey()))
oid := owner.NewIDFromNeo3Wallet(wallet2)

c, _ := client.New(
	client.WithDefaultECDSAPrivateKey(&key.PrivateKey),
	client.WithURIAddress("s01.neofs.devenv:8080", nil),
)
st, _ := c.CreateSession(context.TODO(), math.MaxUint64)
sessionOpts := client.WithSession(st)

wg := sync.WaitGroup{}
for i := 0; i < 500; i++ {
	wg.Add(1)
	go func() {
		defer wg.Done()
		c.ListContainers(context.TODO(), oid, sessionOpts)

		var opts2 object.SearchFilters
		opts2.AddRootFilter()
		opts2.AddFilter(object.AttributeFileName, "tmp11", object.MatchStringEqual)
		c.SearchObject(context.TODO(), new(client.SearchObjectParams).WithContainerID(address.ContainerID()).WithSearchFilters(opts2), sessionOpts)

		opts3 := new(client.GetObjectParams).WithAddress(address)
		c.GetObject(context.TODO(), opts3, sessionOpts)
	}()
}
wg.Wait()

Note:

  • If use sessionOpts := client.WithSession(nil) it works correct.
  • To reproduce this on v1.28.0 need more gorutines

link to issue in s3-gate

cthulhu-rider pushed a commit to cthulhu-rider/neofs-api-go that referenced this issue Jul 6, 2021
…on token

Create new `SessionTokenBody` instead of using one from the parameter in
order to prevent data corruption.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
cthulhu-rider pushed a commit that referenced this issue Jul 6, 2021
Create new `SessionTokenBody` instead of using one from the parameter in
order to prevent data corruption.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
cthulhu-rider pushed a commit to cthulhu-rider/neofs-api-go that referenced this issue Jul 6, 2021
…on token

Create new `SessionTokenBody` instead of using one from the parameter in
order to prevent data corruption.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
cthulhu-rider pushed a commit that referenced this issue Jul 6, 2021
Create new `SessionTokenBody` instead of using one from the parameter in
order to prevent data corruption.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
@alexvanin
Copy link
Contributor

Closed in #324 and #326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants