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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
convto
September 13, 2024
Technology
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Investigating How gob Binary Output Changes Across Go Versions
Asakusa.go #3 での発表資料です
convto
September 13, 2024
More Decks by convto
See All by convto
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
800
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
700
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
400
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.7k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
2.3k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
610
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.5k
みんなでたのしむ math/big / i love math big
convto
0
360
Go1.22からの疑似乱数生成器について/go-122-pseudo-random-generator
convto
2
1.1k
Other Decks in Technology
See All in Technology
[DroidKaigi 2026] Making UI specifications visible: Android UI development in the AI agent era supported by Compose Screenshot Testing and galleries
syarihu
0
550
いかに伝えるか 〜新卒エンジニアの教育のための、ライトノベル活用の一例
ikedon
1
190
AI活用の現在地、 ちゃんと見えてますか?/XPfest-2026
visional_engineering_and_design
0
140
【視聴者参加型!】AWSセキュリティアンチパターンクイズ
syoshie
0
370
Level Up Your CDK DX: 5 Tools I’ve Been Building
gotok365
2
190
Hub & Spoke 環境のネットワークルーティングを分解してみる
tsuyataku
1
520
bet_ai_day_2026_session02
agenticsec
1
930
IoTハンズオンの舞台裏
shirouz
2
110
【試作】IoT x AIエージェント
happysamurai294
0
120
KPIだけでは評価できないプロダクトが考えるべき Evalsという第二の評価系 / Beyond KPIs: Evals as a Second Evaluation Framework for Products #PdEConf
aki_iinuma
4
3.5k
AIエージェントの開発・提供におけるセキュリティリスクの論点と対策
flatt_security
1
560
ブラウザアプリの継続的パフォーマンスモニタリング (序) / Continuous Browser Application Performance Monitoring; Act 1
moznion
0
110
Featured
See All Featured
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Being A Developer After 40
akosma
91
590k
Building AI with AI
inesmontani
PRO
1
1.2k
Abbi's Birthday
coloredviolet
3
9.7k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
270
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
490
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
The Spectacular Lies of Maps
axbom
PRO
1
970
Discover your Explorer Soul
emna__ayadi
2
1.3k
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 な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました