一般的な Unix 系 OS では未マップ領域の読み取り、読取専用ページへの書き込み、実行不可ページでの実行など、許可されないアクセスを示す。シンボル付きコアダンプやデバッガで命令、アクセス種別、アドレス、レジスタ、メモリマップ、スレッドのスタックを調べる。ヌル、破損、解放済みのアドレスはポインタや寿命の問題を示唆する。スタックポインタがガードページ近くにあり、再帰フレームが多い、または巨大なローカル領域があれば枯渇を疑う。スタック破壊は両方に見えることがあり、原因の書き込みはもっと前かもしれない。サニタイザ、最小再現例、割り当てと寿命の追跡で原因を探る。
通常の参照は初期化時に適切なオブジェクトに結び付け、あとで別の対象に結び直せません。int& r = a のあと r = b は b の値を a に代入します。ポインタはアドレスを持つオブジェクトで、別の対象に向けたり nullptr にしたりできます。有効な参照には null 状態がありませんが、対象の寿命を保証するわけではなく、対象の破棄後はどちらもダングリングになり得ます。生ポインタも参照もそれ自体は所有権を表しません。必須の借用には参照、任意の借用にはポインタ、寿命を管理する場合は所有権を表す型を使います。
int x = 1;
const int cx = 2;
int& rx = x;
auto a = rx; // int, copy of x
auto b = cx; // int, top-level const dropped
const auto& c = cx; // const int&, reference preserved by declaration
a = 10; // does not change x
#include <iostream>
struct S {
int x;
};
int main() {
int a; // default-initialized: indeterminate value
int b{}; // value/list-initialized: zero
S s{}; // aggregate/value initialization: s.x is zero
std::cout << b << ' ' << s.x << '\n';
(void)a; // reading a would be undefined behavior
}
1. Expand: add new nullable column user_display_name.
2. Deploy compatible code: write both name and user_display_name; read new if present, else old.
3. Backfill: copy name -> user_display_name in small batches.
4. Validate: compare counts/checksums/null rates and monitor errors.
5. Switch: read only user_display_name after confidence.
6. Contract: stop writing old name, then drop old column in a later release.
ReadPolicy EVENTUAL(max_staleness=2s):
choose healthy replica with lag <= 2s; else primary or error depending on SLA
ReadPolicy READ_YOUR_WRITES(session_lsn):
choose replica only if replay_lsn >= session_lsn;
otherwise wait briefly or route to primary
ReadPolicy STRONG:
route to primary