Skip to content

Commit

Permalink
Rearrange struct members to avoid 64-bit int alignment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertchen committed Jul 27, 2018
1 parent e499a24 commit fce4234
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/duplicacy_chunkoperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type ChunkOperatorTask struct {

// ChunkOperator is capable of performing multi-threaded operations on chunks.
type ChunkOperator struct {
numberOfActiveTasks int64 // The number of chunks that are being operated on
storage Storage // This storage
threads int // Number of threads
taskQueue chan ChunkOperatorTask // Operating goroutines are waiting on this channel for input
stopChannel chan bool // Used to stop all the goroutines
numberOfActiveTasks int64 // The number of chunks that are being operated on

fossils []string // For fossilize operation, the paths of the fossils are stored in this slice
fossilsLock *sync.Mutex // The lock for 'fossils'
Expand Down

2 comments on commit fce4234

@TheBestPessimist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't exactly understand this fix: is it simply to move the 64bit variables (i suppose that's a long) at the beginning of the struct, as first fields? (in this case there's only 1 field)

Why is this a problem though?

@nriley
Copy link

@nriley nriley commented on fce4234 Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a problem with a 32-bit ABI. My guess is that it triggered an unaligned access due to the way the structure was packed. See #469 for the problem that this fixed for me (and @gilbertchen noted this was an issue with atomic access).

Please sign in to comment.