Skip to content

Use of cx_Oracle module appears to break subprocess module #376

@ambercap

Description

@ambercap

I have encountered a bizarre bug. If I create an instance of cx_Oracle, from that point onwards, the returncode from a process created with subprocess.Popen will always be 0 even when the process exit code is non-zero!

The error is neither a hang nor a crash - it causes failed child processes to appear to succeed even when they fail.

The problem is reproducible 100% of the time using this simple script - the output follows:

#!/bin/python3

import sys
import platform

print("platform.platform:", platform.platform())
print("sys.maxsize > 2**32:", sys.maxsize > 2**32)
print("platform.python_version:", platform.python_version())

# Order of the following imports does not make any difference

import subprocess
import cx_Oracle

print("cx_Oracle.version:", cx_Oracle.version)
print("cx_Oracle.clientversion:", cx_Oracle.clientversion())
print('')

print('The following command will fail and a non-zero exit code is expected:')
rc = subprocess.Popen(('cat', 'no_such_file')).wait()
print(f'rc: expected: 1, actual: {rc}')

print('Invoking cx_Oracle - from this point onwards, ALL child processes will always return ')
print('a zero returncode (SUCCESS) even when the process returns a non-zero code!')
connection = cx_Oracle.Connection(mode = cx_Oracle.SYSDBA)
connection.close()
connection = None

print('The following command will fail so a non-zero exit code is expected,')
print('yet subprocess will now return 0:')
rc = subprocess.Popen(('cat', 'no_such_file')).wait()
print(f'rc: expected: 1, actual: {rc}')

The output:

platform.platform: Linux-3.10.0-957.el7.x86_64-x86_64-with-centos-7.6.1810-Core
sys.maxsize > 2**32: True
platform.python_version: 3.6.6
cx_Oracle.version: 7.2.1
cx_Oracle.clientversion: (18, 3, 0, 0, 0)

The following command will fail and a non-zero exit code is expected:
cat: no_such_file: No such file or directory
rc: expected: 1, actual: 1
Invoking cx_Oracle - from this point onwards, ALL child processes will always return 
a zero returncode (SUCCESS) even when the process returns a non-zero code!
The following command will fail and a non-zero exit code is expected,
yet subprocess will now return 0:
cat: no_such_file: No such file or directory
rc: expected: 1, actual: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions