From 4f9e2acc930d595b7826f51d87f25d0d64e680f7 Mon Sep 17 00:00:00 2001 From: George Fleming Date: Thu, 21 Apr 2016 10:03:39 -0700 Subject: [PATCH] Fixes seg fault when Get-Help cannot find topic --- .../help/HelpNotFoundException.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/help/HelpNotFoundException.cs b/src/System.Management.Automation/help/HelpNotFoundException.cs index 5b8771886..3cf3a2b19 100644 --- a/src/System.Management.Automation/help/HelpNotFoundException.cs +++ b/src/System.Management.Automation/help/HelpNotFoundException.cs @@ -62,7 +62,11 @@ namespace Microsoft.PowerShell.Commands /// private void CreateErrorRecord() { - _errorRecord = new ErrorRecord(new ParentContainsErrorRecordException(this), "HelpNotFound", ErrorCategory.ResourceUnavailable, null); + string errMessage = string.Format(HelpErrors.HelpNotFound, _helpTopic); + + // Don't do ParentContainsErrorRecordException(this), as this causes recursion, and creates a + // segmentation fault on Linux + _errorRecord = new ErrorRecord(new ParentContainsErrorRecordException(errMessage), "HelpNotFound", ErrorCategory.ResourceUnavailable, null); _errorRecord.ErrorDetails = new ErrorDetails(typeof(HelpNotFoundException).GetTypeInfo().Assembly, "HelpErrors", "HelpNotFound", _helpTopic); }