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

panic: runtime error: cgo argument has Go pointer to Go pointer when using FIFOQueueV2 with non scalar shapes #14891

Closed
is8ac opened this issue Nov 26, 2017 · 2 comments
Assignees
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower

Comments

@is8ac
Copy link

is8ac commented Nov 26, 2017

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Arch Linux
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 1.4.0
  • Python version: NA, using go bindings
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory: NA, using CPU
  • Exact command to reproduce:

Describe the problem

When using op.FIFOQueueV2() from the go bindings and passing it only scalar shapes in op.FIFOQueueV2Shapes, the OP works as expected. However when using multi dimensional shapes, it panics with panic: runtime error: cgo argument has Go pointer to Go pointer.

Source code / logs

For a working example with scalar shapes, replace the dataShapes and data lines with the commented versions below them.

package main

import (
	"fmt"

	tf "github.com/tensorflow/tensorflow/tensorflow/go"
	"github.com/tensorflow/tensorflow/tensorflow/go/op"
)

func main() {
	s := op.NewScope()
	dataType := []tf.DataType{tf.Int32}

	dataShapes := []tf.Shape{tf.MakeShape(2)} // Panics
	//dataShapes := []tf.Shape{tf.ScalarShape()} // Works

	data := op.Const(s, []int32{3, 4}) // Panics
	//data := op.Const(s, int32(3)) // Works

	queue := op.FIFOQueueV2(s, dataType, op.FIFOQueueV2Shapes(dataShapes))
	enqueue := op.QueueEnqueueV2(s, queue, []tf.Output{data})
	components := op.QueueDequeueV2(s, queue, dataType)
	graph, err := s.Finalize()
	if err != nil {
		panic(err)
	}
	sess, err := tf.NewSession(graph, nil)
	if err != nil {
		panic(err)
	}
	_, err = sess.Run(nil, nil, []*tf.Operation{enqueue})
	if err != nil {
		panic(err)
	}
	results, err := sess.Run(nil, components, nil)
	if err != nil {
		panic(err)
	}
	fmt.Println(results[0].Value())
}
[isaac@d6-arch tfes]$ go run queue_shape_error.go 
2017-11-26 14:51:13.523481: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
github.com/tensorflow/tensorflow/tensorflow/go.setAttr.func21(0xc42000e040, 0x1, 0x1, 0xe4a9c0, 0xc714a0, 0xc42000e040, 0xc42001614c, 0x1)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/graph.go:308 +0x100
github.com/tensorflow/tensorflow/tensorflow/go.setAttr(0xe4a9c0, 0xc42000e038, 0x4dc10a, 0x6, 0x4b6e00, 0xc42000c100, 0x0, 0x0)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/graph.go:309 +0x9b0
github.com/tensorflow/tensorflow/tensorflow/go.(*Graph).AddOperation(0xc42000e028, 0x4dcaa4, 0xb, 0x4dcaa4, 0xb, 0x0, 0x0, 0x0, 0xc42007c1e0, 0xc42008e1b8, ...)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/graph.go:176 +0x4a0
github.com/tensorflow/tensorflow/tensorflow/go/op.(*Scope).AddOperation(0xc42007c180, 0x4dcaa4, 0xb, 0x4dcaa4, 0xb, 0x0, 0x0, 0x0, 0xc42007c1e0, 0x7f05e202e000)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/op/scope.go:83 +0xa0
github.com/tensorflow/tensorflow/tensorflow/go/op.FIFOQueueV2(0xc42007c180, 0xc4200160e8, 0x1, 0x1, 0xc420057f40, 0x1, 0x1, 0x0, 0x7f05e20322f8)
	/home/isaac/go/src/github.com/tensorflow/tensorflow/tensorflow/go/op/wrappers.go:5136 +0x1ea
main.main()
	/home/isaac/go/src/github.com/is8ac/tfes/queue_shape_error.go:20 +0x238
exit status 2
@tatatodd
Copy link
Contributor

@asimshankar might have some ideas here.

@tatatodd tatatodd added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 28, 2017
@asimshankar asimshankar self-assigned this Nov 28, 2017
@asimshankar
Copy link
Contributor

Thanks for the report, this is indeed a bug, will send out a fix.

sb2nov pushed a commit to sb2nov/tensorflow that referenced this issue Dec 1, 2017
By respecting cgo rules on pointers.
Without the change to graph.go, the newly added test would fail with:

panic: runtime error: cgo argument has Go pointer to Go pointer

in the call to the C function TF_SetAttrShapeList.

Fixes tensorflow#14891

PiperOrigin-RevId: 177336663
@sb2nov sb2nov closed this as completed in 78a4873 Dec 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower
Projects
None yet
Development

No branches or pull requests

3 participants