Search Postgresql Archives

Re: ERROR: invalid memory alloc request size 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"John Hagstrand" <john.hagstrand@interageresearch.com> writes:
> How do I get a stack trace?

Assuming you're using a system that has gdb ---

Start psql in one terminal window.  Determine the PID of the backend
process attached to it (ps and/or the pg_stat_activity view will help
you here).  In another window, become the postgres user, and run gdb
to attach to the process:
	gdb /path/to/postgres-executable PID-of-process
	... gdb prints a bunch of junk and then prompts for a command ...
	gdb>
At this point issue two commands:
	b errfinish
	cont
Now go back to the psql window and issue the troublesome command.  gdb
should pop up reporting a breakpoint stop at errfinish (and your psql
session will be hung).  In gdb issue a "bt" command to get a backtrace.
Copy and paste the output, send it along.  Issue "quit" to gdb to get
out of it, or "cont" if you want to inspect more errors.

A typical example gdb session is attached.  Note that you won't get this
detailed a trace unless you compiled with --enable-debug.  However, if
you don't see any routine names at all (just numbers) then you've got an
executable that was "stripped" of all symbolic information.  Such a
trace will be useless, unfortunately; you'd have to recompile at least
an unstripped binary to tell me anything.

			regards, tom lane

$ gdb /home/postgres/testversion/bin/postgres 16088
Attaching to program: /home/postgres/testversion/bin/postgres, process 16088

warning: The shared libraries were not privately mapped; setting a
breakpoint in a shared library will not work until you rerun the program.


warning: Can't find file postmaster referenced in dld_list.
Reading symbols from /usr/lib/libc.1...done.
Reading symbols from /usr/local/lib/libz.sl...done.
Reading symbols from /usr/lib/libdld.1...done.
0xc0142dd8 in ?? () from /usr/lib/libc.1
(gdb) b errfinish
Breakpoint 1 at 0x2a194c: file elog.c, line 311.
(gdb) cont
Continuing.

Breakpoint 1, errfinish (dummy=0) at elog.c:311
311             int                     elevel = edata->elevel;
(gdb) bt
#0  errfinish (dummy=0) at elog.c:311
#1  0x24dc80 in int4div (fcinfo=0x0) at int.c:650
#2  0x18c83c in ExecMakeFunctionResult (fcache=0x400fcec0,
    econtext=0x400fd050, isNull=0x7b03bcc0 "@\013\233\220", isDone=0x0)
    at execQual.c:1050
#3  0x18cf58 in ExecEvalFunc (fcache=0x400fcec0, econtext=0x400fd050,
    isNull=0x7b03bcc0 "@\013\233\220", isDone=0x0) at execQual.c:1431
#4  0x18e778 in ExecEvalExprSwitchContext (expression=0x400fcec0,
    econtext=0x400fd050, isNull=0x7b03bcc0 "@\013\233\220", isDone=0x0)
    at execQual.c:2520
#5  0x1e3bb8 in evaluate_expr (expr=0x400fcec0, result_type=23)
    at clauses.c:2213
#6  0x1e33fc in evaluate_function (funcid=154, result_type=23,
    args=0x400b9cf0, func_tuple=0xc0064b70) at clauses.c:1806
#7  0x1e3298 in simplify_function (funcid=154, result_type=23,
    args=0x400b9cf0, allow_inline=1 '\001', active_fns=0x0) at clauses.c:1732
#8  0x1e282c in eval_const_expressions_mutator (node=0x400b9480,
    active_fns=0x0) at clauses.c:1141
#9  0x1e4b8c in expression_tree_mutator (node=0x400b9bb0,
    mutator=0x40011eca <DINFINITY+2954>, context=0x0) at clauses.c:2986
#10 0x1e300c in eval_const_expressions_mutator (node=0x400b9bb0,
    active_fns=0x0) at clauses.c:1574
#11 0x1e4afc in expression_tree_mutator (node=0x400b9bd0,
---Type <return> to continue, or q <return> to quit---
    mutator=0x40011eca <DINFINITY+2954>, context=0x0) at clauses.c:2973
#12 0x1e300c in eval_const_expressions_mutator (node=0x400b9bd0,
    active_fns=0x0) at clauses.c:1574
#13 0x1e26f8 in eval_const_expressions (node=0x0) at clauses.c:1069
#14 0x1d92d0 in preprocess_expression (parse=0x400b9140, expr=0x0, kind=1)
    at planner.c:401
#15 0x1d9070 in subquery_planner (parse=0x400b9140, tuple_fraction=0)
    at planner.c:228
#16 0x1d8edc in planner (parse=0x400b9140, isCursor=0 '\000', cursorOptions=0)
    at planner.c:119
#17 0x21fccc in pg_plan_query (querytree=0x400b9140) at postgres.c:651
#18 0x21fd6c in pg_plan_queries (querytrees=0x0, needSnapshot=0 '\000')
    at postgres.c:718
#19 0x21ffb0 in exec_simple_query (query_string=0x400b8c80 "select 1/0;")
    at postgres.c:876
#20 0x222d54 in PostgresMain (argc=4, argv=0x4000d888,
    username=0x40050a00 "postgres") at postgres.c:2981
#21 0x1ee51c in BackendRun (port=0x4005cef0) at postmaster.c:2697
#22 0x1edcfc in BackendStartup (port=0x4005cef0) at postmaster.c:2330
#23 0x1ec470 in ServerLoop () at postmaster.c:1167
#24 0x1ebf18 in PostmasterMain (argc=3, argv=0x7b03ab10) at postmaster.c:928
#25 0x1ac358 in main (argc=3, argv=0x7b03ab10) at main.c:257
#26 0xc0065784 in ?? () from /usr/lib/libc.1
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /home/postgres/testversion/bin/postgres, process 16088
$ 

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux