Skip to content

Segmentation Fault MacOS with Python 3.13 #484

Open
@MCubek

Description

@MCubek
  1. What versions are you using?

Oracle ATP 19.c

platform.platform: macOS-15.4-arm64-arm-64bit-Mach-O
sys.maxsize > 2**32: True
platform.python_version: 3.13.3

oracledb.version: 3.1.0

  1. Is it an error or a hang or a crash?

Segmentation Fault Crash

  1. What error(s) or behavior you are seeing?

https://gist.github.com/MCubek/ffa2806d8bf0a8e73fe3ac4436d888ed

This issue does not happen on Python 3.12.

  1. Does your application call init_oracle_client()?

Yes, thick mode is used.

  1. Include a runnable Python script that shows the problem.

Test script below couldn't reproduce the issue but represents how the pool is created...

# Minimal settings (replace placeholders)
username = "your_user"
password = "your_password"
dsn = "your_dsn" 
wallet_path = "/path/to/your/oracle/wallet"
instant_client_path = "/path/to/your/instantclient"


if __name__ == "__main__":
    # Initialize Oracle client (thick mode)
    print("Initializing Oracle Client...")
    oracledb.init_oracle_client(lib_dir=instant_client_path, config_dir=wallet_path)

    # Attempt creating a connection pool (crashes here on Python 3.13)
    print("Creating Oracle connection pool...")
    pool = oracledb.create_pool(
        user=username,
        password=password,
        config_dir=wallet_path,
        dsn=dsn,
        wallet_location=wallet_path,
        wallet_password="",
        min=1,
        max=2,
        increment=1,
    )

    print("Acquiring connection from pool...")
    with pool.acquire() as connection:
        print("Oracle DB version:", connection.version)

    print("Test completed successfully (if no crash).")

In production FastAPI is used to create pool as shown in snippets:

@asynccontextmanager
async def lifespan(app: FastAPI):
    # Create the connection pool
    app.state.pool = create_db_connection_pool()
    yield
    # Close the connection pool on shutdown
    app.state.pool.close()
    logger.debug("Closed Oracle database connection pool.")

if os.getenv("ENV_FOR_DYNACONF") != "test":
    # noinspection PyUnresolvedReferences
    oracledb.init_oracle_client(
        lib_dir=settings.db.instant_client_library, config_dir=wallet_path
    )


def create_db_connection_pool() -> oracledb.ConnectionPool:
    logger.debug("Creating Oracle database connection pool...")
    pool = oracledb.create_pool(
        user=username,
        password=password,
        config_dir=wallet_path,
        dsn=dsn,
        wallet_location=wallet_path,
        wallet_password="",
        min=1,  # Minimum number of connections in the pool
        max=5,  # Maximum number of connections in the pool
        increment=1,  # Number of connections to add when more are needed
    )
    logger.debug("Created Oracle database connection pool.")
    return cast("oracledb.ConnectionPool", pool)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions