---
title: "Unraveling a Postgres segfault that uncovered an Arm64 JIT compiler bug"
description: "Postgres crashes with segfaults on Arm64 instances were traced to JIT-compiled tuple-deforming code, and ultimately to a bug in LLVM's Arm64 code generation."
url: "https://swe.quest/articles/unraveling-a-postgres-segfault-that-uncovered-an-arm64-jit-compiler-bug-3a4fc2ffe09ef0c2"
canonical: "https://www.datadoghq.com/blog/engineering/unraveling-a-postgres-segfault/"
source: "Datadog Engineering"
published: "2025-01-15"
difficulty: "hard"
kind: "Incident"
reading_minutes: 19
tags: ["postgres","compilers","debugging","hardware","incident-response"]
---

# Unraveling a Postgres segfault that uncovered an Arm64 JIT compiler bug

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2025-01-15, 19 min read, Incident. Original: [https://www.datadoghq.com/blog/engineering/unraveling-a-postgres-segfault/](https://www.datadoghq.com/blog/engineering/unraveling-a-postgres-segfault/)

## Summary

Postgres crashes with segfaults on Arm64 instances were traced to JIT-compiled tuple-deforming code, and ultimately to a bug in LLVM's Arm64 code generation. A debug build plus GDB assembly-level stepping showed a jump-table branch in the JIT'd deform function loading zeros and looping forever, with the failing code generated by the switch statement in slot\_compile\_deform. Disabling JIT (\`SET jit = off\`) was an immediate mitigation with no noticeable latency impact. Reproducing the bug required matching the production CPU architecture, and the root cause was fixed upstream.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Incidents & postmortems](https://swe.quest/tags/incident-response.md) (Reliability & operations)

## Prerequisites

- PostgreSQL query execution ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- GDB debugging ([easy posts on Debugging](https://swe.quest/tags/debugging.md?difficulty=easy))
- Arm64 assembly basics
- JIT compilation concepts ([easy posts on Compilers](https://swe.quest/tags/compilers.md?difficulty=easy))

## Keywords

PostgreSQL, LLVM, Arm64, JIT, GDB, slot\_compile\_deform, AWS EC2

## Related posts

- [Porting the Solana eBPF JIT compiler to ARM64](https://swe.quest/articles/porting-the-solana-ebpf-jit-compiler-to-arm64-2640f585a04d44ad.md): Trail of Bits · 2022-10-12 · Hard · 11 min read · Compilers, Runtimes & VMs, Rust, Sandboxing & isolation, Memory safety
  Solana's RBPF JIT compiler, which translates eBPF smart contracts to native code on validators, was ported from x86-only to ARM64, and its x86 backend gained Windows support.
- [Postgres WASM by Snaplet and Supabase](https://swe.quest/articles/postgres-wasm-by-snaplet-and-supabase-a942df855beab1df.md): Supabase · 2022-10-03 · Medium · 9 min read · PostgreSQL, WebAssembly, Virtualization, Browsers, Networking
  postgres-wasm runs a full PostgreSQL 14 server in the browser by emulating an x86 machine with v86 rather than compiling Postgres to WASM directly.
- [Fuzzing rust-minidump for Embarrassment and Crashes – Part 2](https://swe.quest/articles/fuzzing-rust-minidump-for-embarrassment-and-crashes-part-2-036e58ccd9566822.md): Mozilla Hacks · 2022-06-23 · Medium · 16 min read · Testing, Rust, Debugging, Vulnerability research
  Fuzzing rust-minidump with cargo-fuzz and libfuzzer turned up a series of real bugs in a Rust rewrite of Breakpad's minidump processor that had otherwise shipped cleanly.
- [Incident Report: September 22nd, 2025](https://swe.quest/articles/incident-report-september-22nd-2025-f36fdb64699f52a7.md): Railway · 2025-09-22 · Medium · 5 min read · Incidents & postmortems, PostgreSQL, Schema migrations, Resilience, Deployment
  A schema change removing an unused column was partially reverted by a later code change, breaking a core API and leaving Railway's project canvas stuck loading.
- [Supabase is now on Postgres 13.3](https://swe.quest/articles/supabase-is-now-on-postgres-13-3-2931acd8ef3ece75.md): Supabase · 2021-07-26 · Easy · 3 min read · PostgreSQL, Performance engineering
  New Supabase projects now run Postgres 13.3 (up from 12.0), bringing native gen\_random\_uuid, parallel index vacuuming, incremental sorting and smaller B-tree indexes.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
