Re: Don't clean up LLVM state when exiting in a bad way
Zhihong Yu <zyu@yugabyte.com>
From: Zhihong Yu <zyu@yugabyte.com>
To: Jelte Fennema <Jelte.Fennema@microsoft.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2021-08-18T15:17:54Z
Lists: pgsql-hackers
On Wed, Aug 18, 2021 at 8:01 AM Jelte Fennema <Jelte.Fennema@microsoft.com> wrote: > Hi, > > I ran into some segfaults when using Postgres that was compiled with LLVM > 7. According to the backtraces these crashes happened during the call to > llvm_shutdown, during cleanup after another out of memory condition. It > seems that calls to LLVMOrcDisposeInstance, can crash (at least on LLVM 7) > when LLVM is left in bad state. I attached the relevant part of the > stacktrace to this email. > > With the attached patch these segfaults went away. The patch turns > llvm_shutdown into a no-op whenever the backend is exiting with an error. > Based on my understanding of the code this should be totally fine. No > memory should be leaked, since all memory will be cleaned up anyway once > the backend exits shortly after. The only reason this cleanup code even > seems to exist at all is to get useful LLVM profiling data. To me it seems > be acceptable if the profiling data is incorrect/missing when the backend > exits with an error. > > Jelte > Hi, Minor comment: + * shut LLVM down, this can result into a segfault. So if this process result into a segfault -> result in a segfault Cheers
Commits
-
jit: Do not try to shut down LLVM state in case of LLVM triggered errors.
- dccffd9a274d 11.14 landed
- c49e6f9d9749 13.5 landed
- 43849b65f333 12.9 landed
- edb4d95ddf89 15.0 landed
- 4e86887e0922 14.0 landed