Open shirabez opened 4 years ago
Hi @shirabez ,
Would you be able to enable core dumps, then reproduce the issue, and then extract the backtrace of the crash from the resulting core dump?
Information on how to enable core dumps can be found in issue #218.
i.e.:
sudo yum install postgresql12-debuginfo
sudo tee /etc/systemd/system/postgresql-12.service.d/limitcore.conf <<EOF
[Service]
LimitCORE=infinity
EOF
sudo systemctl daemon-reload
sudo systemctl restart postgresql-12
sudo tee /etc/sysctl.d/postgres_core.conf <<EOF
# Set the path to the core dumps
kernel.core_pattern = /core_dumps
# Add the PID to the end of the file name
kernel.core_uses_pid = 1
# Allow setuid processes to dump core. Is this necessary for Postgres?
fs.suid_dumpable = 2
EOF
mkdir /core_dumps
chmod 0777 /core_dumps
You may need to recompile tds_fdw with -ggdb
in PG_CPPFLAGS
.
When you have a core dump, the backtraces can be extracted like this:
sudo gdb --batch --eval-command="thread apply all bt full" $(which postmaster) ${core_file_path}
Thanks for the swift reply, Geoff. Hoping to get this to you this week.
Hi, I confirm this bug. I use PostgreSQL 10 on Windows. PostgreSQL v. 10.11 Microsoft SQL Server 2017 Express Edition tds_fwd v.2.0.1 compiled with MS Visual C++ 2010 Unfortunately I don't know how to get core dump on Windows. Thank you Adam
I found small workaroud: change SELECT INTO X COUNT() FROM Y to dynamic EXECUTE 'SELECT COUNT() FROM Y' INTO X
@adamb111 if you have clear instructions about how to build tds_fdw at Windows, can you share them?
We could add them to a README, and maybe it could help us reproducing the problems.
@GeoffMontee Here is the backtrace from a core dump:
[New LWP 3557] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `postgres: 12/main: postgres [REDACTED DATABASE NAME] [local] SELECT '. Program terminated with signal SIGSEGV, Segmentation fault.
Thread 1 (Thread 0x7f209e6f3840 (LWP 3557)):
No symbol table info available.
old_cxt = <optimized out>
festate = 0x55a6a0396038
estate = 0x55a6a03943a0
__func__ = "tdsEndForeignScan"
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
No symbol table info available.
Thanks, @shirabez. That seems odd. It seems to be segfaulting when freeing the connection's query variable:
https://github.com/tds-fdw/tds_fdw/blob/v2.0.1/src/tds_fdw.c#L1929
My instruction, how to compile tds_fdw on Windows. compilation _tds_fdw_on_windows.txt
Thanks, the instructions are really clear.
I will see if I can create a generic README for Windows, or even better, some kind of recipe to ease stuff and prevent errors :-)
Hello, I have the same error as @shirabez on: CentOS-7, PostgreSQL 10.7 Moreover it happens also when I execute same prepared statement twice. (as far as i know Postgres executes sql in plpgsql as prepared statements, so i think it may be the same issue). I'll be happy to provide more information if needed. Regards.
Postgresql: 12.1 tds-fdw: 2.0.1
I have a PostgreSQL plpgsql function that does a SELECT INTO X COUNT(*) on a SQL Server foreign table where X is a local variable declared in the function. The function runs fine the first time it is executed. On the second execution, it causes a seg fault. It's very consistent. That is, every second run of the function causes the Postgres server to raise a signal 11 seg fault.
Other details:
So I'm thinking the issue is with tds-fdw...? Not sure if this is related to issue #51, but I've set match_column_names to both 1 or 0 in the foreign table definition and it seems to make no difference. It always crashes on the second run. Any ideas? Let me know what other info I can provide. Thank you very much.