Segfault in MemoryContextAlloc - Mailing list pgsql-bugs

From Dmitriy Sarafannikov
Subject Segfault in MemoryContextAlloc
Date
Msg-id 1453890275.241158212@f404.i.mail.ru
Whole thread Raw
Responses Re: Segfault in MemoryContextAlloc
List pgsql-bugs
Hi, i caught segfault with a simple select query (column and table names in query were changed).
select id_pk2 from table1 where id_pk1 = '9751302'

primary key is (id_pk1, id_pk2)
table1 is (id_pk1 bigint, id_pk2 bigint, date_add timestamp)


(gdb) bt full
#0 MemoryContextAlloc (context=0x0, size=120) at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/utils/mmgr/mcxt.c:584
No locals.
#1 0x00007f6ecc5b8eec in AfterTriggerBeginXact () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/commands/trigger.c:3913
No locals.
#2 0x00007f6ecc4e8c21 in StartTransaction () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/access/transam/xact.c:1848
s = 0x7f6eccbc4480 <TopTransactionStateData>
#3 StartTransactionCommand () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/access/transam/xact.c:2534
s = 0x7f6eccbc4480 <TopTransactionStateData>
__func__ = "StartTransactionCommand"
#4 0x00007f6ecc6c452d in start_xact_command () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/tcop/postgres.c:2412
No locals.
#5 0x00007f6ecc6c8750 in start_xact_command () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/tcop/postgres.c:1334
No locals.
#6 exec_simple_query (query_string=0x7f6ecceef490 "select id_pk2 from table1 where id_pk1 = '9751302'")
at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/tcop/postgres.c:887
dest = DestRemote
parsetree_list = <optimized out>
save_log_statement_stats = 0 '\000'
was_logged = 0 '\000'
msec_str = "0.515\000\060\000\000\001\000\000\000\000\000\000\210Wk<\375\177\000\000\360\340\352\314n\177\000"
parsetree_item = <optimized out>
isTopLevel = <optimized out>
#7 PostgresMain (argc=<optimized out>, argv=argv@entry=0x7f6ecce6b880, dbname=0x7f6ecce6b850 "dbname", username=<optimized out>)
at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/tcop/postgres.c:4079
query_string = 0x7f6ecceef490 "select id_pk2 from table1 where id_pk1 = '9751302'"
firstchar = 81
input_message = {data = 0x7f6ecceef490 "select id_pk2 from table1 where id_pk1 = '9751302'", len = 70, maxlen = 1024, cursor = 70}
local_sigjmp_buf = {{__jmpbuf = {140725617117552, -4238614924085751285, 1, 140113860802664, 140113861075184, 140113858312064, -4238614923683098101, -4320489016603241973}, __mask_was_saved = 1,
__saved_mask = {__val = {0, 140728898420735, 140113857730256, 140113860681408, 140113822954592, 0, 51, 0, 140725617117920, 140725617117920, 140113854018386, 140113858289216, 0, 140725617117920,
0, 0}}}}
send_ready_for_query = 0 '\000'
__func__ = "PostgresMain"
#8 0x00007f6ecc48e92e in BackendRun (port=0x7f6ecceae0f0) at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/postmaster/postmaster.c:4252
ac = 1
secs = 507195785
usecs = 460872
i = 1
av = 0x7f6ecce6b880
maxac = <optimized out>
#9 BackendStartup (port=0x7f6ecceae0f0) at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/postmaster/postmaster.c:3917
bn = <optimized out>
pid = <optimized out>
#10 ServerLoop () at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/postmaster/postmaster.c:1678
rmask = {fds_bits = {256, 0 <repeats 15 times>}}
selres = <optimized out>
readmask = {fds_bits = {960, 0 <repeats 15 times>}}
now = <optimized out>
last_touch_time = 1453878784
__func__ = "ServerLoop"
#11 0x00007f6ecc67158b in PostmasterMain (argc=5, argv=<optimized out>) at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/postmaster/postmaster.c:1287
opt = <optimized out>
status = <optimized out>
userDoption = <optimized out>
listen_addr_saved = 1 '\001'
i = <optimized out>
output_config_variable = <optimized out>
__func__ = "PostmasterMain"
#12 0x00007f6ecc48fac2 in main (argc=5, argv=0x7f6ecce6a570) at /build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/main/main.c:228
No locals.It seems like TopTransactionContext doesn't initialized and is NULL.

(gdb) print TopTransactionContext
$7 = (MemoryContext) 0x0
--
Best regards,
Dmitriy Sarafannikov

pgsql-bugs by date:

Previous
From: Jan Lentfer
Date:
Subject: Re: Encoding problems with "COMMENT ON DATABASE .." causing pg_restore (and pg_upgrade) to fail
Next
From: Andres Freund
Date:
Subject: Re: Segfault in MemoryContextAlloc