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
160
0
Share
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
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
650
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
370
MCPと認可まわりの話 / mcp_and_authorization
convto
2
1.4k
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
2k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
570
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
3.3k
みんなでたのしむ math/big / i love math big
convto
0
340
Go1.22からの疑似乱数生成器について/go-122-pseudo-random-generator
convto
2
1k
Go1.20からサポートされるtree構造のerrの紹介と、treeを考慮した複数マッチができるライブラリを作った話/introduction of tree structure err added since go 1_20
convto
0
1.4k
Other Decks in Technology
See All in Technology
AIエージェントの支払い基盤 AgentCore Payments概要
kmiya84377
2
190
おいらのAWSアップデートの追い方〜Slack×AgentCore〜
yakumo
1
110
AI飲み会幹事エージェントを作っただけなのに
ykimi
0
210
2026年春のAgentCoreアプデ 細かいやつ全部まとめ
minorun365
4
230
JTCでRedmine利用者2700人を実現した手法 第二部
nobuonakamura
0
110
そのSLO 99.9%、本当に必要ですか? 〜優先度付きSLOによる責任共有の設計思想〜 / Is that 99.9% SLO really necessary? Design philosophy of shared responsibility through prioritized SLOs
vtryo
0
740
"うちにはまだ早い"は本当? ─ 小さく始めるPlatform Engineering入門
harukasakihara
6
590
AI-Assisted Contributions and Maintainer Load - PyCon US 2026
pauloxnet
1
140
ESP32 IoTを動かしながらメモリ使用量を観測してみた話
zozotech
PRO
0
130
Terragrunt x Snowflake + dbt で作るマルチテナントなデータ基盤構築プラットフォーム
gak_t12
0
170
LookerとADKで作る社内AIエージェント
chanyou0311
0
220
全社統制を維持しながら現場負担をどう減らすか〜プラットフォームチームとセキュリティチームで進めたSecurity Hub活用によるAWS統制の見直し〜/secjaws-security-hub-custom-insights
mhrtech
1
520
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
Design in an AI World
tapps
1
210
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
230
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
140
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
340
KATA
mclloyd
PRO
35
15k
Building Adaptive Systems
keathley
44
3k
Statistics for Hackers
jakevdp
799
230k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
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 な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました