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

Reorder Scanner fields to fix alignment issues #464

Merged
merged 1 commit into from
Feb 25, 2019
Merged

Reorder Scanner fields to fix alignment issues #464

merged 1 commit into from
Feb 25, 2019

Conversation

WGH-
Copy link
Contributor

@WGH- WGH- commented Feb 25, 2019

Go doesn't always guarantee 64-bit alignment of 64-bit integer, which leads to crashes when atomic operations are used on them on certain platforms (e.g. ARM).

This problem is described here: https://golang.org/pkg/sync/atomic/#pkg-note-BUG

By putting these fields first, proper alignment will be guaranteed.

golang/go#599
golang/go#23345

This is how crash looks like:

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

goroutine 37 [running]:
github.com/google/certificate-transparency-go/scanner.(*Scanner).processEntry(0xfb2120, 0x1fb09886, 0x0, 0xf06000, 0x62e, 0x630, 0x10de000, 0xbda, 0xbdc, 0x3570f0, ...)
        /home/wgh/go/src/github.com/google/certificate-transparency-go/scanner/scanner.go:108 +0x34
github.com/google/certificate-transparency-go/scanner.(*Scanner).matcherJob(0xfb2120, 0xd4e2c0, 0x3570f0, 0x3570f0)
        /home/wgh/go/src/github.com/google/certificate-transparency-go/scanner/scanner.go:183 +0x80
github.com/google/certificate-transparency-go/scanner.(*Scanner).ScanLog.func2(0xc105e0, 0xfb2120, 0xd4e2c0, 0x3570f0, 0x3570f0, 0x1)
        /home/wgh/go/src/github.com/google/certificate-transparency-go/scanner/scanner.go:287 +0xd0
created by github.com/google/certificate-transparency-go/scanner.(*Scanner).ScanLog
        /home/wgh/go/src/github.com/google/certificate-transparency-go/scanner/scanner.go:284 +0x200
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x11f70]

Go doesn't always guarantee 64-bit alignment of 64-bit integer,
which leads to crashes when atomic operations are used on them
on certain platforms (e.g. ARM).

This problem is described here: https://golang.org/pkg/sync/atomic/#pkg-note-BUG

By putting these fields first, proper alignment will be guaranteed.

golang/go#599
golang/go#23345
@codecov
Copy link

codecov bot commented Feb 25, 2019

Codecov Report

Merging #464 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #464   +/-   ##
=======================================
  Coverage   66.55%   66.55%           
=======================================
  Files          88       88           
  Lines       10658    10658           
=======================================
  Hits         7093     7093           
  Misses       2964     2964           
  Partials      601      601
Impacted Files Coverage Δ
scanner/scanner.go 56.68% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c58afd...c87d746. Read the comment docs.

@daviddrysdale daviddrysdale merged commit 17cd42b into google:master Feb 25, 2019
@daviddrysdale
Copy link
Contributor

Well spotted, thank you.

@WGH- WGH- deleted the arm-atomic-alignment-fix branch February 25, 2019 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants