RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1976169 - mod_wsgi segfaults when python program outputs a warning message
Summary: mod_wsgi segfaults when python program outputs a warning message
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: mod_wsgi
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: beta
: ---
Assignee: Luboš Uhliarik
QA Contact: Branislav Náter
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-06-25 11:52 UTC by Alfredo Moralejo
Modified: 2021-12-07 22:08 UTC (History)
6 users (show)

Fixed In Version: mod_wsgi-4.7.1-7.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-12-07 22:04:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Alfredo Moralejo 2021-06-25 11:52:06 UTC
Description of problem:

When testing OpenStack on current compose of CentOS Stream 9 we are hitting the problem reported in:

https://github.com/GrahamDumpleton/mod_wsgi/issues/650

The program we are running under wsgi creates following warnings:

/usr/lib/python3.9/site-packages/oslo_utils/fnmatch.py:24: DeprecationWarning: Using the oslo.utils's 'fnmatch' module is deprecated, please use the stdlib 'fnmatch' module.                
  debtcollector.deprecate(                                                                                                                                                                   
/usr/lib/python3.9/site-packages/aodh/storage/impl_sqlalchemy.py:112: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade                       
  self._engine_facade = db_session.EngineFacade(self.dress_url(url),                                                                                                                         
/usr/lib/python3.9/site-packages/aodh/storage/impl_sqlalchemy.py:112: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade                       
  self._engine_facade = db_session.EngineFacade(self.dress_url(url),             

and mod_wsgi crashes with following stack:

 Process 73780 (httpd) of user 978 dumped core.
                                                   
                                                   Stack trace of thread 73810:
                                                   #0  0x00007f9d04be6395 Log_write (mod_wsgi_python3.so + 0xe395)
                                                   #1  0x00007f9d049a0469 method_vectorcall_VARARGS (libpython3.9.so.1.0 + 0x126469)
                                                   #2  0x00007f9d049a20df PyObject_VectorcallMethod (libpython3.9.so.1.0 + 0x1280df)
                                                   #3  0x00007f9d049d406e _textiowrapper_writeflush (libpython3.9.so.1.0 + 0x15a06e)
                                                   #4  0x00007f9d04a29ba9 _io_TextIOWrapper_write (libpython3.9.so.1.0 + 0x1afba9)
                                                   #5  0x00007f9d04997a77 method_vectorcall_O (libpython3.9.so.1.0 + 0x11da77)
                                                   #6  0x00007f9d049839f0 _PyEval_EvalFrameDefault (libpython3.9.so.1.0 + 0x1099f0)
                                                   #7  0x00007f9d04990373 function_code_fastcall (libpython3.9.so.1.0 + 0x116373)
                                                   #8  0x00007f9d0498378d _PyEval_EvalFrameDefault (libpython3.9.so.1.0 + 0x10978d)
                                                   #9  0x00007f9d04990373 function_code_fastcall (libpython3.9.so.1.0 + 0x116373)
                                                   #10 0x00007f9d04a01223 PyObject_CallOneArg.lto_priv.22 (libpython3.9.so.1.0 + 0x187223)
                                                   #11 0x00007f9d04a4b09a warn_explicit (libpython3.9.so.1.0 + 0x1d109a)
                                                   #12 0x00007f9d04a4a938 do_warn (libpython3.9.so.1.0 + 0x1d0938)
                                                   #13 0x00007f9d04a4a7fc PyErr_WarnEx (libpython3.9.so.1.0 + 0x1d07fc)
                                                   #14 0x00007f9d048e2d5f convertsimple.cold (libpython3.9.so.1.0 + 0x68d5f)
                                                   #15 0x00007f9d0498c002 vgetargs1_impl (libpython3.9.so.1.0 + 0x112002)
                                                   #16 0x00007f9d0498be1a PyArg_ParseTuple (libpython3.9.so.1.0 + 0x111e1a)
                                                   #17 0x00007f9d04be635b Log_write (mod_wsgi_python3.so + 0xe35b)
                                                   #18 0x00007f9d049a0469 method_vectorcall_VARARGS (libpython3.9.so.1.0 + 0x126469)
                                                   #19 0x00007f9d049a20df PyObject_VectorcallMethod (libpython3.9.so.1.0 + 0x1280df)
                                                   #20 0x00007f9d049d406e _textiowrapper_writeflush (libpython3.9.so.1.0 + 0x15a06e)
                                                   #21 0x00007f9d04a29ba9 _io_TextIOWrapper_write (libpython3.9.so.1.0 + 0x1afba9)
                                                   #22 0x00007f9d04997a77 method_vectorcall_O (libpython3.9.so.1.0 + 0x11da77)
                                                   #23 0x00007f9d049839f0 _PyEval_EvalFrameDefault (libpython3.9.so.1.0 + 0x1099f0)



Version-Release number of selected component (if applicable):


python3-mod_wsgi-4.7.1-4.el9.x86_64

How reproducible:

allways with current openstack which provides some warnings on wsgi services.

Steps to Reproduce:

There is a simple example of reproducer in https://github.com/GrahamDumpleton/mod_wsgi/issues/650

apparently https://github.com/GrahamDumpleton/mod_wsgi/commit/2c9d1b3e725ad2a072e9fef4cb1cb0bb9ae2d540 may be the fix. I'm working to build and test 4.7.1-4 with this patch.

Note this may be a critical issue for many services running on mod_wsgi.

Comment 1 Alfredo Moralejo 2021-06-25 12:14:02 UTC
I've just tested that applying following patch on top of mod_wsgi-4.7.1-6.el9 (last build in cs9 koji), it works fine:

# cat ../SOURCES/mod_wsgi_fix_deprecation.patch
--- a/src/server/wsgi_logger.c  2021-06-25 11:59:23.936000000 +0000
+++ b/src/server/wsgi_logger.c  2021-06-25 12:00:10.257000000 +0000
@@ -223,7 +223,7 @@
     return Py_False;
 }
 
-static void Log_queue(LogObject *self, const char *msg, int len)
+static void Log_queue(LogObject *self, const char *msg, Py_ssize_t len)
 {
     const char *p = NULL;
     const char *q = NULL;
@@ -330,7 +330,7 @@
 static PyObject *Log_write(LogObject *self, PyObject *args)
 {
     const char *msg = NULL;
-    int len = -1;
+    Py_ssize_t len = -1;
 
     WSGIThreadInfo *thread_info = NULL;
 
--- a/src/server/wsgi_python.h  2021-06-25 12:00:38.400000000 +0000
+++ b/src/server/wsgi_python.h  2021-06-25 12:01:15.686000000 +0000
@@ -21,6 +21,8 @@
 
 /* ------------------------------------------------------------------------- */
 
+#define PY_SSIZE_T_CLEAN 1
+
 #include <Python.h>
 
 #if !defined(PY_VERSION_HEX)

Comment 2 Javier Peña 2021-06-25 13:17:27 UTC
Just FTR, the patch mentioned by Alfredo is https://github.com/GrahamDumpleton/mod_wsgi/commit/2c9d1b3e725ad2a072e9fef4cb1cb0bb9ae2d540

Comment 6 Alfredo Moralejo 2021-07-07 11:19:49 UTC
mod_wsgi-4.7.1-7.el9 is not in last compose, it seems blocked by some gate?

Comment 8 Alan Pevec 2021-07-16 22:30:02 UTC
Can be moved to ON_QA, not sure what is the workflow for CS9 bugs, build is in CS9 compose:
https://composes.stream.centos.org/production/latest-CentOS-Stream/compose/AppStream/x86_64/os/Packages/python3-mod_wsgi-4.7.1-7.el9.x86_64.rpm

It works in Puppet OpenStack integration test scenarios.


Note You need to log in before you can comment on or make changes to this bug.