Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
gob バイナリが Go バージョンによって 出力が変わることについて調べてみた / Inve...
Search
convto
September 13, 2024
Technology
200
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
Transcript
17 slides
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 な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました
More Decks by convto
See All by convto
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
6
13k
Go 1.27 の標準パッケージに uuid が入った!のでいろいろ喋る / go_127_std_go_uuid
convto
3
960
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
3
760
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
500
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.8k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
2.5k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
700
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.7k
みんなでたのしむ math/big / i love math big
convto
0
400
Other Decks in Technology
See All in Technology
DBTS2026 盛り上がってますか!?Databricksが実現するAI時代のデータ基盤
akuwano
1
200
Ebitengine製iOSアプリ公開ボタンを押す会
eiei114
0
120
AWS Quick 入門 | 目指せ Quick マスター 01
inariku
PRO
2
340
地域社会の実情からITエンジニアの社会貢献を考える
sms_tech
0
170
農夫は秘伝のタレを知らない - NOBODY KNOWS THE HIDDEN SOURCE - Kaggriculture 3rd Place Solution
masspeaks
0
260
Microsoft Entra Kerberos で実現するクラウド デバイス管理
tamaiyutaro
2
680
81天的 AI Agent 軟體開發團隊治理實務分享
regionbbs
0
160
速くなった開発の効果をどう推し量るのか
bulbulpaul
0
110
AI時代の組織作り:チーム開発から「個人×AI」への移行と、持続可能な「開発資本」の築き方
ham0215
3
840
JAWSコミュニティに 参加して1年経った結果
ssakita
0
140
田んぼから始まる挑戦 〜新米農家の1年目〜
miu_crescent
PRO
0
230
Kiro Web 入門 (サインインから、頼み方、PR の受け取り、クラウドの決まりまで) | 目指せ Kiro マスター 04
inariku
PRO
2
100
Featured
See All Featured
Accessibility Awareness
sabderemane
1
300
Marketing to machines
jonoalderson
1
6k
Exploring anti-patterns in Rails
aemeredith
4
560
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
240
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
We Have a Design System, Now What?
morganepeng
55
8.4k
How STYLIGHT went responsive
nonsquared
100
6.4k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Test your architecture with Archunit
thirion
2
2.5k
GitHub's CSS Performance
jonrohan
1033
470k