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

Reading from multiple segments doesn't work #97

Closed
recht opened this issue Oct 4, 2017 · 4 comments
Closed

Reading from multiple segments doesn't work #97

recht opened this issue Oct 4, 2017 · 4 comments
Labels
Milestone

Comments

@recht
Copy link

recht commented Oct 4, 2017

I have an idl like this:

using Go = import "/go.capnp";

@0xb87bcd826779968d;
$Go.package("test");
struct Document {
  assoc @0 :List(Assoc);

  struct Assoc {
    kind @0 :UInt32;
  }
}

struct GeneratorData {
  documents @0 :List(Document);
}

Given this test:

func TestMulti(t *testing.T) {
	a := capnp.MultiSegment(nil)
	msg, seg, err := capnp.NewMessage(a)
	require.NoError(t, err)

	root, err := NewRootGeneratorData(seg)
	require.NoError(t, err)

	count := 10000
	docs, err := root.NewDocuments(int32(count))
	require.NoError(t, err)

	for i := 0; i < count; i++ {
		d := docs.At(i)
		_, err := d.NewAssoc(100)
		require.NoError(t, err)
	}

	root, err = ReadRootGeneratorData(msg)
	require.NoError(t, err)

	_, err = root.Documents()
	require.NoError(t, err)
}

There will be an error on the last line where it tries to read out the value. It seems that this happens when objects cross segments somehow?

I have my own MultiSegment implementation, which I assumed was the issue, but it looks as if there's a problem in general?

@zombiezen zombiezen added the bug label Oct 4, 2017
@zombiezen zombiezen added this to the 2.17 milestone Oct 4, 2017
@zombiezen
Copy link
Contributor

Very possible/probable. The multi-segment codepaths aren't as well-tested as single-segment. I'll take a look.

@zombiezen
Copy link
Contributor

@recht, I'm unable to reproduce a failure using the test case you gave me. Can you give me what error message you saw on the last line? Please also include output from go env GOOS GOARCH and go version.

@recht
Copy link
Author

recht commented Oct 19, 2017

--- FAIL: TestMulti (0.91s)
	Error Trace:	capnp_store_test.go:296_memorystore
	Error:		Received unexpected error capnp: invalid pointer address

My go env:

OARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/joakim/gocode"
GORACE=""
GOROOT="/pack/go"
GOTOOLDIR="/pack/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build105259280=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

And go version: go version go1.9.1 linux/amd64

@zombiezen
Copy link
Contributor

While doing some entirely unrelated work, I managed to reproduce this issue and I have a smaller test case that I can dig into. I'll work on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants