From 6a5cd9a820988df29c41047db69d497f59bce23a Mon Sep 17 00:00:00 2001 From: Manu Lange Date: Thu, 8 Aug 2019 11:50:41 +1200 Subject: [PATCH] prevent recursive logging csharp stackoverflow. (#59503) * prevent recursive logging situation. * Add changelog --- changelogs/fragments/59503-fix-recursive-csharp-logging.yml | 2 ++ lib/ansible/module_utils/csharp/Ansible.Basic.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/59503-fix-recursive-csharp-logging.yml diff --git a/changelogs/fragments/59503-fix-recursive-csharp-logging.yml b/changelogs/fragments/59503-fix-recursive-csharp-logging.yml new file mode 100644 index 00000000000..3c746029cd1 --- /dev/null +++ b/changelogs/fragments/59503-fix-recursive-csharp-logging.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible.basics - fix core C# recursive call when logging fails (e.g. if insufficient permissions are held) (https://github.com/ansible/ansible/pull/59503) diff --git a/lib/ansible/module_utils/csharp/Ansible.Basic.cs b/lib/ansible/module_utils/csharp/Ansible.Basic.cs index 6a7d03fdcb5..d1011c860ff 100644 --- a/lib/ansible/module_utils/csharp/Ansible.Basic.cs +++ b/lib/ansible/module_utils/csharp/Ansible.Basic.cs @@ -304,7 +304,8 @@ namespace Ansible.Basic } catch (System.Security.SecurityException) { - Warn(String.Format("Access error when creating EventLog source {0}, logging to the Application source instead", logSource)); + // Cannot call Warn as that calls LogEvent and we get stuck in a loop + warnings.Add(String.Format("Access error when creating EventLog source {0}, logging to the Application source instead", logSource)); logSource = "Application"; } }