#6696 Warn about sys.exc_info()
Closed: fixed 6 years ago Opened 7 years ago by cheimes.

It's a rare known fact that sys.exc_info() can lead to memory leaks-like issues. sys.exc_info() returns a frame object that keeps all local objects of a stack frame alive. If the stack frame object happens to be kept in local scope or attached to any object that is referenced by an object in local scope or any parent stack frame, a reference cycle is created.

Usually references cycles are broken up by gc after a while, but it can take a while. However, if any object in a reference cycle has a del method, than Python 2 cannot break the reference cycles and all objects are kept alive until the end of the process. In Python 3 the cycles gc will forcefully break open the cycle eventually. Forcefully is still problematic. The gc may not run some cleanups.

Good news, we don't use sys.exc_info() in functions yet that run in long-running processes like WSGI server. We should make sure to keep it that way (pylint checker?).

By the way some calls can be replaced with log.info(msg, exc_info=True). ipapython.install.core needs some finally: exc_info = None to be safe.

./ipaserver/install/installutils.py:                tb = sys.exc_info()[2]
./ipapython/admintool.py:            traceback = sys.exc_info()[2]
./ipapython/install/util.py:            exc_info = sys.exc_info()
./ipapython/install/util.py:            exc_info = sys.exc_info()
./ipapython/install/core.py:                exc_info = sys.exc_info()
./ipapython/install/core.py:                exc_info = sys.exc_info()
./ipapython/install/core.py:            exc_info = sys.exc_info()

Metadata Update from @cheimes:
- Issue assigned to jcholast
- Issue set to the milestone: 0.0 NEEDS_TRIAGE

7 years ago

Metadata Update from @pvoborni:
- Custom field affects_doc reset
- Custom field tester adjusted to wanted
- Issue close_status updated to: None
- Issue set to the milestone: Future Releases (was: 0.0 NEEDS_TRIAGE)

7 years ago

FreeIPA does not use sys.exc_info() in long-running applications like daemons or WSGI. For short-running scripts it's not severe enough.

Metadata Update from @cheimes:
- Issue assigned to cheimes (was: jcholast)

6 years ago

Metadata Update from @cheimes:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

6 years ago

Login to comment on this ticket.

Metadata