Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Inve...
Search
convto
September 13, 2024
Technology
0
150
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Investigating How gob Binary Output Changes Across Go Versions
Asakusa.go #3 での発表資料です
convto
September 13, 2024
Tweet
Share
More Decks by convto
See All by convto
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
610
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
340
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.1k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
1.7k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
530
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.1k
みんなでたのしむ math/big / i love math big
convto
0
310
Go1.22からの疑似乱数生成器について/go-122-pseudo-random-generator
convto
2
940
Go1.20からサポートされるtree構造のerrの紹介と、treeを考慮した複数マッチができるライブラリを作った話/introduction of tree structure err added since go 1_20
convto
0
1.3k
Other Decks in Technology
See All in Technology
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
680
形式手法特論:コンパイラの「正しさ」は証明できるか? #burikaigi / BuriKaigi 2026
ytaka23
15
3.6k
BidiAgent と Nova 2 Sonic から考える音声 AI について
yama3133
2
140
なぜ あなたはそんなに re:Invent に行くのか?
miu_crescent
PRO
0
250
Claude Codeを使った情報整理術
knishioka
19
12k
「アウトプット脳からユーザー価値脳へ」がそんなに簡単にできたら苦労しない #RSGT2026
aki_iinuma
6
3.4k
AI との良い付き合い方を僕らは誰も知らない (WSS 2026 静岡版)
asei
1
210
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.9k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.5k
_第4回__AIxIoTビジネス共創ラボ紹介資料_20251203.pdf
iotcomjpadmin
0
170
Oracle Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
2
660
Next.js 16の新機能 Cache Components について
sutetotanuki
0
210
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
0
450
The SEO Collaboration Effect
kristinabergwall1
0
320
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
390
We Are The Robots
honzajavorek
0
130
Abbi's Birthday
coloredviolet
0
4.2k
[SF Ruby Conf 2025] Rails X
palkan
0
680
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
54
48k
It's Worth the Effort
3n
187
29k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
250
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
270
Designing for Performance
lara
610
70k
Transcript
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた 2024/09/13 Asakusa.go #3
自己紹介 @convto 株式会社LayerX所属 (読みはこんぶとです)
gob ってなに? - Go が標準パッケージで実装してる独自のエンコーディング! - 仕様とかくわしく知りたい人はこちらをご覧ください https://speakerdeck.com/convto/understanding-gob-encoding - きょうは
5min LT なので全員完全理解者だと思って話を進めます
ある日知人から以下のタレコミをうける
タレコミ - なんか Go のバージョンによって gob の出力が異なるんだけど - marshal/unmarshal 間の互換性はありそう
- どこで変わったんだろうね
確認してみる
確認してみる
None
cnt: 36 id: -64 cnt: 12 id: 64 cnt: 37
id: -65 cnt: 12 id: 65
なんか typedef / value の id がずれてそう - たしかに出力は変わっている -
id の値が変わっている - id = 65 だと typedef がちょうど 1byte で表現できないため、古い方は ちょっと勿体無い - 先頭 1bit が終端判定、末尾 1bit が正負判定。値が 6bit で収まる なら 1byte で表現できる。65 はちょうどたりない
どこで入った? - 霊感で 1.21 まで比べてみたら 1.23 と一致してた $ diff -s
<(go1.21.0 run main.go) <(go1.23.0 run main.go) Files /dev/fd/11 and /dev/fd/12 are identical - 1.20.1 系では挙動に差がない $ diff -s <(go1.20.1 run main.go) <(go1.20.14 run main.go) Files /dev/fd/11 and /dev/fd/12 are identical - 1.21 に上がる時に入っているはず!
見つけた! https://go-review.googlesource.com/c/go/+/460543/4 /src/encoding/gob/type.go#b184
id ずれた理由 - firstUserId = 64 が定義されてて user 定義の型は id
= 64 から始ま る - とりあえず nextId +1 から確保してたのが止まって 64 から使えるように なったという話っぽい!
スッキリ
知人に伝えて平和が訪れた
感想 - marshal/unmarshal の互換を担保した上で encoded な値が変わるこ とはちょいちょいある - よくあるのはフィールド順番担保されないとか。今回は typeid
が揃わな かった - encoded な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました