Skip to content

Protect getattr from recursion - #31544

Merged
cachedout merged 1 commit into
saltstack:2015.8from
DSRCorporation:issues/29701_getattr_recursion_protection
Feb 29, 2016
Merged

cachedout merged 1 commit into
saltstack:2015.8from
DSRCorporation:issues/29701_getattr_recursion_protection

Conversation

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor

What does this PR do?

Protect SyncWrapper.__getattribute__() from infinity recursion if called on an object having no attribute async. This happens if constructor raises an error before the attribute is assigned after this __del__ method checks for the attribute that downs the code into the recursion calls to __getattribute

What issues does this PR fix or reference?

Fixes salt-call errors on accessing /etc/salt/pki/minion:

Exception ValueError: 'I/O operation on closed file' in <bound method SyncWrapper.__del__ of <salt.utils.async.SyncWrapper object at 0x28a3f50>> ignored

mentioned in #27063 and #29701.

Previous Behavior

SyncWrapper goes to the infinitie recursion calls until the stack limit is reached if an exception throwed in SyncWrapper.__init__() that could produce a number of different errors.

New Behavior

Don't use custrom code to get the async attribute in __getattribute__ if it requested. Just use basic object logic for this case.

Tests written?

  • Yes
  • No

@cachedout

Copy link
Copy Markdown
Contributor

Wow! Nice fix here, @DmitryKuzmenko .

Comment thread salt/utils/async.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pass is no longer necessary. Let's take it out.

@DmitryKuzmenko
DmitryKuzmenko force-pushed the issues/29701_getattr_recursion_protection branch from cd0b306 to b7a45b8 Compare February 29, 2016 16:59
cachedout pushed a commit that referenced this pull request Feb 29, 2016
…ion_protection

Protect getattr from recursion
@cachedout
cachedout merged commit 5a6aff1 into saltstack:2015.8 Feb 29, 2016
@DmitryKuzmenko
DmitryKuzmenko deleted the issues/29701_getattr_recursion_protection branch August 15, 2016 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants