Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminated by signal SIGSEGV (Address boundary error) #827

Closed
varadpatil opened this issue May 23, 2024 · 10 comments
Closed

terminated by signal SIGSEGV (Address boundary error) #827

varadpatil opened this issue May 23, 2024 · 10 comments

Comments

@varadpatil
Copy link

I'm using psycopg3 pool. I fetch data from database using the following code.

@staticmethod
async def sql(pool, sql):
    async with pool.connection() as aconn:
        async with aconn.cursor() as acur:
            await acur.execute(sql)
            return await acur.fetchall()
Current thread 0x0000711be45ff000 (most recent call first):
  File "/home/varad/CWD/algo_trading/dev/tiger/theta_decay2/.venv/lib/python3.10/site-packages/psycopg/types/datetime.py", line 542 in _load_iso
  File "/home/varad/CWD/algo_trading/dev/tiger/theta_decay2/.venv/lib/python3.10/site-packages/psycopg/types/datetime.py", line 507 in load
  File "/home/varad/CWD/algo_trading/dev/tiger/theta_decay2/.venv/lib/python3.10/site-packages/psycopg/_transform.py", line 309 in load_rows
  File "/home/varad/CWD/algo_trading/dev/tiger/theta_decay2/.venv/lib/python3.10/site-packages/psycopg/cursor_async.py", line 195 in fetchall
  File "/home/varad/CWD/algo_trading/dev/tiger/theta_decay2/algo/rm2.py", line 162 in sql

There is no way I can catch this in python itself (or atleast I don't know any way to catch it in python itself). Have anyone faced similar thing?

Here is my verion of psycopg.

psycopg 3.1.19 PostgreSQL database adapter for Python
├── psycopg-pool *
│   └── typing-extensions >=4.4 
├── typing-extensions >=4.1
└── tzdata *

Till the time it is closed, is there any other version that is known to not have this issue?

@dvarrazzo
Copy link
Member

dvarrazzo commented May 23, 2024 via email

@varadpatil
Copy link
Author

There is no specific value, and the same value doesn't always produce error. I run my app again and it may not fail. The behaviour is not regular.

@dvarrazzo
Copy link
Member

dvarrazzo commented May 23, 2024 via email

@varadpatil
Copy link
Author

I'm on Ubuntu Linux.

The query I am executing is simply a SELECT query, with some filters and ORDER BY. The result it is supposed to return has some columns that have timestamp data, but there is no timezone customization. Here is the datatype taken from information_schema.columns for those columns.

        data_type         
--------------------------
 timestamp with time zone
(1 row)

@dvarrazzo
Copy link
Member

dvarrazzo commented May 24, 2024 via email

@varadpatil
Copy link
Author

You are right @dvarrazzo python doesn't give any traceback and just dies. Since I was not able to catch any exception at python level and my program was just dying, I added following lines to my code.

import faulthandler

faulthandler.enable()

This is what is giving the error traceback. Without this It just dies. The fact that there is no python exception that I could catch hints towards something with lower level C.

Also the same value sometimes gives this issue, and sometimes doesn't is hinting towards concurrency issue (or something of that sort). I'm using async connection pool.

This is troubling me, please let me know if any additional information is required. I would request to consider this for fixing.

@akrherz
Copy link

akrherz commented May 24, 2024

I am likely making unhelpful noise here, but when I have seen this type of issue within apps that use "fancy" threading, I add an arbitrary and very early exercise of the offending python API, so that the c module is called before any threading stuff gets loaded. For example if you are using zoneinfo, at the program front end and the first thing it does. This sometimes makes the problem "go-away" and offers a temporary band-aid.

from zoneinfo import ZoneInfo
ZoneInfo("UTC")
import os
import sys ... etc

@dvarrazzo
Copy link
Member

dvarrazzo commented May 24, 2024 via email

@dvarrazzo
Copy link
Member

This is a segfault on a Python statement, so it is a Python bug.

It's an issue I have never found in development, which happened on Ubuntu too. I can only work on it if a proper way to reproduce the issue is provided.

@varadpatil
Copy link
Author

Thanks @akrherz, your unhelpful noise was rather very helpful. I'm no longer getting SIGSEGV. Also thanks @dvarrazzo for looking into it and pointing out that it's comming from Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants