metrics/generic: fix uint64 alignment#1007
Conversation
ed1ab96 to
093af6f
Compare
74f16a5 to
b138422
Compare
|
Sure! Please add a test :) |
|
🤔 sure but could you help me?
I don't write this kind of test every day so any help would be welcome. |
b138422 to
aec653a
Compare
|
@peterbourgon friendly ping 😉 |
|
Sorry, I don't know offhand!
…On Fri, Sep 4, 2020 at 11:11 AM Ludovic Fernandez ***@***.***> wrote:
@peterbourgon <https://github.com/peterbourgon> friendly ping 😉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1007 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA36TLOD4F6AMFECL45YSLSECVMVANCNFSM4QJPZKTA>
.
|
|
Without a 32bit arch it's not possible to create a simple test about alignment problem on a 32bits arch. I see only one solution: be able to run the tests of the project on a CI that use a 32bit arch. In all cases, this kind of change of the CI seems out of the scope of my PR. As a kind of prof, I will give you some dumps. On a 32bit archCreated from an old PI2-B (arm) Previous version:the My version:On a 64bit archPrevious version:My version: |
Well, it's important to the long-term maintainability of the project that changes come with regression tests, so I don't accidentally undo your work in a future refactor. Can you think of any other way to accomplish that? |
|
I put a comment on the structure to explain why the field should be placed at the top of the structure. |
aec653a to
12171c7
Compare
|
I added a test, but it's a weak and complex test, the maintainability is low, because the real solution is to run the tests on a 32-bit arch. FYI even staticcheck is not able to catch this misalignment properly without a 32-bit arch. Currently, I don't know any linter that can properly check this without a 32-bit arch. |
12171c7 to
0250207
Compare
0250207 to
aec4993
Compare
|
@peterbourgon friendly ping 😉 |
|
Wow that is an... astonishing test ;) OK, I'm happy with this. Final question, though — is there a command I could run on the relevant architectures that would return one result if the alignment is "good" and a different result if the alignment was "bad"? |
|
As I explained in the code comment and in my previous message, you just have to run the existing tests or : package main
import (
"fmt"
"github.com/go-kit/kit/metrics/generic"
)
func main() {
counter := generic.Counter{}
counter.Add(6)
fmt.Println(counter)
}go test ./... (on ARM)If you are asking for a linter or something like that: no linter is perfect and this problem is complex, so I can not recommend a tool. |
|
@peterbourgon ping 🙏 |
Fixes uint64 alignment on 32-bit arch.
panic on Counter
panic on Gauge
Related to traefik/traefik#7207