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

Fix(atomic panic): 64-bit fields must be 64-bit aligned on 32-bit systems #358

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions statistic/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ import (
const Name = "MEMORY"

type User struct {
sent uint64
recv uint64
lastSent uint64
lastRecv uint64
sendSpeed uint64
recvSpeed uint64
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64
lastSent uint64
lastRecv uint64
sendSpeed uint64
recvSpeed uint64

hash string
ipTable sync.Map
ipNum int32
Expand Down
10 changes: 8 additions & 2 deletions tunnel/trojan/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ const (
)

type OutboundConn struct {
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64

metadata *tunnel.Metadata
sent uint64
recv uint64
user statistic.User
headerWrittenOnce sync.Once
net.Conn
Expand Down
10 changes: 8 additions & 2 deletions tunnel/trojan/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ import (

// InboundConn is a trojan inbound connection
type InboundConn struct {
// WARNING: do not change the order of these fields.
// 64-bit fields that use `sync/atomic` package functions
// must be 64-bit aligned on 32-bit systems.
// Reference: https://github.com/golang/go/issues/599
// Solution: https://github.com/golang/go/issues/11891#issuecomment-433623786
sent uint64
recv uint64

net.Conn
sent uint64
recv uint64
auth statistic.Authenticator
user statistic.User
hash string
Expand Down