Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-11-05 Thread Anthonin Bonnefoy
On Tue, Nov 5, 2024 at 9:00 AM Thomas Munro wrote: > Reasoning: Old LLVM required C++11. LLVM 9 switched to C++14. LLVM > 14 switched C++17. Pretty soon they'll flip to C++20 or C++23, they > don't mess around. The corresponding -std=c++XX flag finishes up in > our compile lines, because llvm

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-11-05 Thread Thomas Munro
On Thu, Oct 31, 2024 at 9:49 PM Daniel Gustafsson wrote: > > On 31 Oct 2024, at 06:48, Thomas Munro wrote: > > I guess at a minimum a copy of the licence would need to appear somewhere > > That's my interpretation of it as well. > > > perhaps under src/backend/jit/llvm? > > Since SectionMemoryMan

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-10-31 Thread Daniel Gustafsson
> On 31 Oct 2024, at 06:48, Thomas Munro wrote: > I guess at a minimum a copy of the licence would need to appear somewhere That's my interpretation of it as well. > perhaps under src/backend/jit/llvm? Since SectionMemoryManager.h is in src/backend/jit I wonder if it should be a placed in a se

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-10-31 Thread Anthonin Bonnefoy
On Thu, Oct 31, 2024 at 6:49 AM Thomas Munro wrote: > There are a couple of cases of dual-licensed code in our tree where we > explicitly used the Boost alternative instead of Apache 2. I plead > complete ignorance of this topic and defer to those who know about > such things: can we actually do

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-10-30 Thread Thomas Munro
On Thu, Oct 17, 2024 at 10:41 PM Thomas Munro wrote: > Thanks! I'm going to go ahead and commit this. (Sorry for the delay, I got distracted by pgconf.eu.) Today I set out to commit this patch, and wrote a proper commit message to explain the code provenance, circumstances that led to it, and t

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-10-17 Thread Thomas Munro
On Thu, Oct 17, 2024 at 10:36 PM Anthonin Bonnefoy wrote: > I've run some additional tests, mostly pgbench with > options=-cjit_above_cost=0 for an extended duration on an instance > that was impacted. I haven't seen any issues nor performance > regressions compared to the unpatched version. > > I

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-10-17 Thread Anthonin Bonnefoy
I've run some additional tests, mostly pgbench with options=-cjit_above_cost=0 for an extended duration on an instance that was impacted. I haven't seen any issues nor performance regressions compared to the unpatched version. I will switch the commitfest entry to Ready for Committer if there's no

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-30 Thread Anthonin Bonnefoy
I created a commitfest entry[1] to have the CI test the patch. There was a failure in headerscheck and cpluspluscheck when the include of SectionMemoryManager.h is checked[2] In file included from /usr/include/llvm/ADT/SmallVector.h:18, from /tmp/cirrus-ci-build/src/include/jit/SectionMemoryManage

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-29 Thread Anthonin Bonnefoy
On Wed, Aug 28, 2024 at 12:24 AM Thomas Munro wrote: > 2. I tested against LLVM 10-18, and found that 10 and 11 lack some > needed symbols. So I just hid this code from them. Even though our > stable branches support those and even older versions, I am not sure > if it's worth trying to do some

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-27 Thread Thomas Munro
Slightly better version, which wraps the conditional code in #ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER. v5-0001-Backport-of-LLVM-code-to-fix-ARM-relocation-bug.patch Description: Binary data

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-27 Thread Thomas Munro
On Wed, Aug 28, 2024 at 12:07 AM Anthonin Bonnefoy wrote: > On Tue, Aug 27, 2024 at 12:01 PM Thomas Munro wrote: > > Thanks! And that's great news. Do you want to report this experience > > to the PR, in support of committing it? That'd make it seem easier to > > consider shipping a back-porte

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-27 Thread Anthonin Bonnefoy
On Tue, Aug 27, 2024 at 12:01 PM Thomas Munro wrote: > > Thanks! And that's great news. Do you want to report this experience > to the PR, in support of committing it? That'd make it seem easier to > consider shipping a back-ported copy... Yes, I will do that.

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-27 Thread Thomas Munro
Thanks! And that's great news. Do you want to report this experience to the PR, in support of committing it? That'd make it seem easier to consider shipping a back-ported copy...

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-27 Thread Anthonin Bonnefoy
On Tue, Aug 27, 2024 at 1:33 AM Thomas Munro wrote: > I am sure this requires changes for various LLVM versions. I tested > it with LLVM 14 on a Mac where I've never managed to reproduce the > original complaint, but ... h, this might be exacerbated by ASLR, > and macOS only has a small ALSR

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-26 Thread Thomas Munro
On Tue, Aug 27, 2024 at 11:32 AM Thomas Munro wrote: > SectorMemoryManager Erm, "Section". (I was working on some file system stuff at the weekend, and apparently my fingers now auto-complete "sector".)

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-26 Thread Thomas Munro
Here is an experimental attempt to steal the SectorMemoryManager from https://github.com/llvm/llvm-project/pull/71968, rename it to SafeSectorMemoryManager, and inject it as shown in the previous patch. Another approach might be to try to make a new class that derives from SectorMemoryManager and a

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-26 Thread Thomas Munro
On Tue, Aug 27, 2024 at 2:16 AM Anthonin Bonnefoy wrote: > There's a possible alternative, but it's definitely in the same > category as the hot-patching idea. llvmjit uses > LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager to > create the ObjectLinkingLayer and it will be created wit

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-26 Thread Anthonin Bonnefoy
On Mon, Aug 26, 2024 at 4:33 AM Thomas Munro wrote: > IIUC this one is a random and rare crash depending on malloc() and > perhaps also the working size of your virtual memory dart board. > (Annoyingly, I had tried to reproduce this quite a few times on small ARM > systems when earlier reports cam

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-25 Thread Thomas Munro
On Sat, Aug 24, 2024 at 12:22 AM Anthonin Bonnefoy wrote: > On Thu, Aug 22, 2024 at 12:33 PM Thomas Munro wrote: > > I fear that back-porting, for the LLVM project, would mean "we fix it > > in main/20.x, and also back-port it to 19.x". Do distros back-port > > further? > > That's also my fear,

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-23 Thread Anthonin Bonnefoy
On Thu, Aug 22, 2024 at 12:33 PM Thomas Munro wrote: > I fear that back-porting, for the LLVM project, would mean "we fix it > in main/20.x, and also back-port it to 19.x". Do distros back-port > further? That's also my fear, I'm not familiar with distros back-port policy but eyeballing ubuntu p

Re: Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-22 Thread Thomas Munro
On Thu, Aug 22, 2024 at 7:22 PM Anthonin Bonnefoy wrote: > Ideally, the llvm fix will be merged and backported > in llvm but the PR has been open for some time now. I fear that back-porting, for the LLVM project, would mean "we fix it in main/20.x, and also back-port it to 19.x". Do distros back

Segfault in jit tuple deforming on arm64 due to LLVM issue

2024-08-22 Thread Anthonin Bonnefoy
Hi! I have an instance that started to consistently crash with segfault or bus error and most of the generated coredumps had corrupted stacks. Some salvageable frames showed the error happening within ExecRunCompiledExpr. Sure enough, running the query with jit disabled stopped the crashes. The is