Re: 012_subtransactions.pl vs clang -fsanitize=undefined

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 012_subtransactions.pl vs clang -fsanitize=undefined
Дата
Msg-id 1787180.1658701083@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: 012_subtransactions.pl vs clang -fsanitize=undefined  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: 012_subtransactions.pl vs clang -fsanitize=undefined  (Thomas Munro <thomas.munro@gmail.com>)
Список pgsql-hackers
I wrote:
> I think what's happening is just that this build configuration
> eats stack extravagantly.

That's definitely it, but I don't entirely see why.  Here are a
couple of major offenders though:

(gdb) x/8i ExecInterpExpr
   0x11a5530 <ExecInterpExpr>:  push   %rbp
   0x11a5531 <ExecInterpExpr+1>:        mov    %rsp,%rbp
   0x11a5534 <ExecInterpExpr+4>:        sub    $0x2f40,%rsp
   0x11a553b <ExecInterpExpr+11>:       mov    %rdi,-0x10(%rbp)
   0x11a553f <ExecInterpExpr+15>:       mov    %rsi,-0x18(%rbp)
   0x11a5543 <ExecInterpExpr+19>:       mov    %rdx,-0x20(%rbp)
   0x11a5547 <ExecInterpExpr+23>:       jmpq   0x11a554c <ExecInterpExpr+28>
   0x11a554c <ExecInterpExpr+28>:       cmpq   $0x0,-0x10(%rbp)

(gdb) p 0x2f40
$51 = 12096

(gdb) x/8i ExecInitExprRec
   0x11672e0 <ExecInitExprRec>: push   %rbp
   0x11672e1 <ExecInitExprRec+1>:       mov    %rsp,%rbp
   0x11672e4 <ExecInitExprRec+4>:       sub    $0x3c80,%rsp
   0x11672eb <ExecInitExprRec+11>:      mov    %rdi,-0x8(%rbp)
   0x11672ef <ExecInitExprRec+15>:      mov    %rsi,-0x10(%rbp)
   0x11672f3 <ExecInitExprRec+19>:      mov    %rdx,-0x18(%rbp)
   0x11672f7 <ExecInitExprRec+23>:      mov    %rcx,-0x20(%rbp)
   0x11672fb <ExecInitExprRec+27>:      lea    -0x60(%rbp),%rdi

(gdb) p 0x3c80
$52 = 15488

It looks like this build eats about 24K of stack per plpgsql recursion
level, of which ExecInterpExpr alone accounts for half.  Why is that?
It has no large local variables, mostly just ints and pointers.
There are a lot of them, but even if you presume that each one gets
its own dedicated bit of the stack frame, it's hard to arrive at 12K.

I'd almost call this a compiler bug.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: Custom tuplesorts for extensions
Следующее
От: Thomas Munro
Дата:
Сообщение: Re: 012_subtransactions.pl vs clang -fsanitize=undefined