This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: returned a result with an error set
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: EliRibble, serhiy.storchaka, xiang.zhang
Priority: normal Keywords:

Created on 2018-02-08 15:28 by EliRibble, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
Screen Shot 2018-02-08 at 8.28.00 AM.png EliRibble, 2018-02-08 15:28 Screencapture of error details in sentry
Messages (6)
msg311836 - (view) Author: Eli Ribble (EliRibble) Date: 2018-02-08 15:28
We've had about 200 occurrences of this error in various parts of our code. I have captured stack traces using sentry so I may be able to provide more detail if requested. The ultimate problem is that a SystemError is raised from within contextlib. The message of the SystemError is:

"<class 'contextlib._GeneratorContextManager'> returned a result with an error set"

The code, according to sentry, that is emitting this error is:

python3.6/contextlib.py in helper at line 159
            <cleanup>
    """
    @wraps(func)
    def helper(*args, **kwds):
>        return _GeneratorContextManager(func, args, kwds)
    return helper

I'm reporting this bug primarily because of the documentation at https://docs.python.org/3/library/exceptions.html#SystemError and I'm using CPython
msg311840 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-08 17:36
Since contextlib._GeneratorContextManager is implemented in Python, it is unlikely that it is a culprit of the error. Do you use any third-party extensions? Likely some extension provoked the error.

Can you provide a minimal script that reproduces the issue?
msg311851 - (view) Author: Eli Ribble (EliRibble) Date: 2018-02-08 20:24
To my knowledge, no, we don't use any python extensions. Unless extensions can be installed via pip, in which case I would need to audit our many dependencies to determine if any of them ultimately pull in any extensions as part of a pip install.

I can't provide a minimal script, no, we don't reproduce it deterministically. Like I said, our application runs all the time and we appear to have about ~200 instances where the problem has been caught by our uncaught exception handling system. The repro of the bug does not appear to have a set correlation with exercise of a particular feature or a particular application state. Given the exception is a thin wrapper around linux syscalls, my guess is something like select(), it's likely the issue has to do with transient network communication problems.
msg313861 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-15 09:04
What is the full version of Python you used? If this is not 3.6.3 does upgrading to 3.6.3 help? Try also with 3.6.4rc1 and the beta of 3.7.

Do you use threads, forking, signal handlers? Is it synchronous or asynchronous code? Could you show the code of the function decorated with the contextmanager (or asynccontextmanager) decorator and the code that uses this context manager?

With such little information we can fix a bug only by accident, when fixing other bugs or during refactoring. And there is a chance that it is already fixed in 3.6.3, 3.6.4rc1 or 3.7.
msg313914 - (view) Author: Eli Ribble (EliRibble) Date: 2018-03-15 20:44
You can feel free to close the bug - I no longer work for the company that had this problem and I was only reporting the bug because the documentation specifically requested I do so. I don't have the ability now to try upgrading the version of Python to see if it resolves the problem. I also no longer have access to the stack traces.

The code in question did not use threading, forking or signal handlers and I no longer have the rights to provide the wrapped code.
msg315556 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-04-21 07:55
Our application also runs into this error today and this is an occasional error that we didn't encounter before and can't reproduce currently. Although our application uses the outdated 2.7.5 but the problem looks similar. Our exception traceback points to `PyCell_Get`:

...
RROR nova.api.openstack   File "/opt/cloud/services/cascading-nova/venv/lib/python2.7/site-packages/keystonemiddleware/auth_token/_cache.py", line 222, in get
RROR nova.api.openstack     with self._cache_pool.reserve() as cache:
RROR nova.api.openstack   File "/usr/lib64/python2.7/contextlib.py", line 84, in helper
RROR nova.api.openstack     return GeneratorContextManager(func(*args, **kwds))
RROR nova.api.openstack SystemError: /home/abuild/rpmbuild/BUILD/Python-2.7.5/Objects/cellobject.c:24: bad argument to internal function
History
Date User Action Args
2022-04-11 14:58:57adminsetgithub: 76980
2018-04-21 07:55:23xiang.zhangsetstatus: closed -> open

versions: + Python 2.7
nosy: + xiang.zhang

messages: + msg315556
resolution: works for me ->
stage: resolved ->
2018-03-16 02:27:43ned.deilysetstatus: open -> closed
resolution: works for me
stage: resolved
2018-03-15 20:44:23EliRibblesetmessages: + msg313914
2018-03-15 09:04:25serhiy.storchakasetmessages: + msg313861
2018-02-08 20:24:23EliRibblesetmessages: + msg311851
2018-02-08 17:36:34serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg311840
2018-02-08 15:28:27EliRibblecreate