Tools & extensions / Article
Memory safety for Postgres extensions in C/C++
ClickHouse engineers explain why Postgres's MemoryContext and palloc model plus PG_TRY/PG_CATCH longjmp error handling interact badly with C++ exceptions and object destructors in extensions. They describe the different isolation strategies used in pg_clickhouse, pg_re2, pg_chdb and pg_stat_ch, and state that routing via ereport(FATAL) is a mitigation rather than a crash-isolation guarantee.
Read the originalWhy it’s in the collection
Concrete, experience-based guidance for writing or reviewing C/C++ extensions where Postgres error paths can skip C++ cleanup.
THE CONVERSATION
Found on Hacker News 2
Links lead to the original story or comment where this resource appeared. Titles identify the surrounding discussion.