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
110
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
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
4
1.2k
Go 関連の個人的おもしろCVE 5選 / my favorite go cve
convto
3
430
バイナリを眺めてわかる gob encoding の仕様と性質、適切な使い方 / understanding gob encoding
convto
6
2.7k
みんなでたのしむ math/big / i love math big
convto
0
270
Go1.22からの疑似乱数生成器について/go-122-pseudo-random-generator
convto
2
790
Go1.20からサポートされるtree構造のerrの紹介と、treeを考慮した複数マッチができるライブラリを作った話/introduction of tree structure err added since go 1_20
convto
0
1.1k
byte列のbit表現を得るencodingライブラリ作った
convto
1
1.2k
Go runtimeの歩き方/how to follow go runtime function
convto
1
1k
入出金ドメインの苦労話と解決へのアプローチ/funds in/out difficulties and solutions
convto
2
1.4k
Other Decks in Technology
See All in Technology
標準技術と独自システムで作る「つらくない」SaaS アカウント管理 / Effortless SaaS Account Management with Standard Technologies & Custom Systems
yuyatakeyama
2
1k
AIエージェントの継続的改善のためオブザーバビリティ
pharma_x_tech
6
1.4k
Uniadex__公開版_20250617-AIxIoTビジネス共創ラボ_ツナガルチカラ_.pdf
iotcomjpadmin
0
150
あなたの声を届けよう! 女性エンジニア登壇の意義とアウトプット実践ガイド #wttjp / Call for Your Voice
kondoyuko
1
170
Snowflake Summit 2025 データエンジニアリング関連新機能紹介 / Snowflake Summit 2025 What's New about Data Engineering
tiltmax3
0
240
【TiDB GAME DAY 2025】Shadowverse: Worlds Beyond にみる TiDB 活用術
cygames
0
900
AWS Summit Japan 2025 Community Stage - App workflow automation by AWS Step Functions
matsuihidetoshi
1
150
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
2
390
より良いプロダクトの開発を目指して - 情報を中心としたプロダクト開発 #phpcon #phpcon2025
bengo4com
1
390
PHPでWebブラウザのレンダリングエンジンを実装する
dip_tech
PRO
0
180
Observability infrastructure behind the trillion-messages scale Kafka platform
lycorptech_jp
PRO
0
130
Claude Code Actionを使ったコード品質改善の取り組み
potix2
PRO
4
1.7k
Featured
See All Featured
Building Adaptive Systems
keathley
43
2.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Building an army of robots
kneath
306
45k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Statistics for Hackers
jakevdp
799
220k
Speed Design
sergeychernyshev
31
1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
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 な値に対して一致するか確認する、みたいな処理は秘孔をつく 可能性があるのでやめておきましょう
ご清聴ありがとうございました