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

SetLimit crashes with arm32 #570

Closed
jduranf opened this issue Oct 28, 2020 · 2 comments
Closed

SetLimit crashes with arm32 #570

jduranf opened this issue Oct 28, 2020 · 2 comments
Assignees

Comments

@jduranf
Copy link

jduranf commented Oct 28, 2020

Using arm32, when the function buffer.SetLimit(bl) is called in source_node.go, the service crash:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11f08]

goroutine 20 [running]:
runtime/internal/atomic.goStore64(0x25ed134, 0x19000, 0x0)
	/usr/local/go/src/runtime/internal/atomic/atomic_arm.go:144 +0x1c
github.com/emqx/kuiper/xstream/nodes.(*DynamicChannelBuffer).SetLimit(...)
	/home/jduran/go/src/github.com/emqx/kuiper/xstream/nodes/dynamic_channel_buffer.go:29
github.com/emqx/kuiper/xstream/nodes.(*SourceNode).Open.func1.1(0x25bc140, 0x25b6240, 0x70e270, 0x25f3bc0, 0x70d918, 0x25f3900, 0x25ed000, 0x25ef76c, 0x0)
	/home/jduran/go/src/github.com/emqx/kuiper/xstream/nodes/source_node.go:127 +0xca0
created by github.com/emqx/kuiper/xstream/nodes.(*SourceNode).Open.func1
	/home/jduran/go/src/github.com/emqx/kuiper/xstream/nodes/source_node.go:80 +0x1dc

This is due to a bad alignment:
golang/go#23345
https://stackoverflow.com/questions/28670232/atomic-addint64-causes-invalid-memory-address-or-nil-pointer-dereference

And can be easily fixed by changing the variables order in this structure:

type DynamicChannelBuffer struct {
	In     chan api.SourceTuple
	Out    chan api.SourceTuple
	buffer []api.SourceTuple
	limit  int64
}

by:

type DynamicChannelBuffer struct {
	limit  int64
	In     chan api.SourceTuple
	Out    chan api.SourceTuple
	buffer []api.SourceTuple
}
@ngjaying
Copy link
Collaborator

Thank you @jduranf for the very detail explanation. PR merged.

@jduranf
Copy link
Author

jduranf commented Oct 29, 2020

Thank you for the quick fix!

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

No branches or pull requests

2 participants