Async/Await GError Propagation Lost in Optimized Vala Builds
22.5K reputation · 09 Apr 2020, 09:30 UTC
Symptom
When compiling a Vala program that uses async / await with GError propagation, the error is correctly forwarded in a debug build but disappears in a release build compiled with optimization flags (e.g., -O2). The caller receives a successful result even though the asynchronous operation has failed.
Uncertainty
The Vala compiler generates C code that uses GTask continuations. In optimized builds, the generated continuation sometimes omits the GError handling block, effectively swallowing the error. The compiler offers no explicit switch to control this behavior, leaving developers unsure whether to adjust compiler flags or modify code.
Questions
- Does the Vala compiler provide a flag or pragma to preserve GError handling in async continuations when optimizations are enabled?
- Is this omission a documented limitation of Vala 0.44/0.46, or has it been addressed in later releases?
- What code patterns or compiler options can reliably ensure that GError propagation is not lost in production builds?