在 VS 代码中调试 C# Azure 函数时出现分段错误
Segmentation fault while debuggin a C# Azure Function in VS Code
-
visual-studio-code
-
azure-functions
-
vscode-debugger
-
azure-functions-core-tools
-
azure-durable-functions
使用
在本地开发一堆 Azure 函数
- Windows 10 个 64 位
- Visual Studio代码
- C#/.NET 核心
一切都很好。我能够在本地开发和调试我的 Azure 函数,然后将它们部署到 Azure。然而一天前,我从 netcoreapp2.2
升级到 netcorepp3.1
。这是我目前的 settings.json
{
"azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish",
"azureFunctions.templateFilter": "Verified"
}
现在我仍然可以通过按 F5
启动本地调试会话。但是当我尝试对 localhost:7071
API 地址发出 http 请求时,调试器会话终止并显示以下消息:
...
[7/30/2020 8:21:32 PM] f4f4622abc054ed29ac69f1210a204a8: Function 'GetScorecardsByActionTargetType (Orchestrator)' completed. ContinuedAsNew: False. IsReplay: False. Output: (332 bytes). State: Completed. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 8.
[7/30/2020 8:21:32 PM] Executed 'GetScorecardsByActionTargetType' (Succeeded, Id=11f2a673-851e-4afb-9ed6-81f6e3eefc8d)
Stack overflow.
/d/Users/xxx/AppData/Roaming/npm/func: line 14: 2125 Segmentation fault node "$basedir/node_modules/azure-functions-core-tools/lib/main.js" "$@"
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'func host start'" terminated with exit code: 139.
关于升级过程中发生什么问题的任何想法(我假设升级是导致它的原因)?
编辑:
我注释掉了我正在处理的新功能(编排)。相反,我尝试在调试器中 运行 升级之前使用的旧编排之一,我没有改变。这个旧函数与新函数在同一个本地函数项目中。
这里是终端 Window 抄本:
[7/31/2020 3:30:48 AM] Task hub worker started. Latency: 00:00:02.1744949. InstanceId: . Function: . HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 1.
[7/31/2020 3:30:48 AM] Host started (2892ms)
[7/31/2020 3:30:48 AM] Job host started
Hosting environment: Production
Content root path: D:\Users\xxx\Documents\VisSources\PolTrackCosmosDbFunctions\bin\Debug\netcoreapp3.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[7/31/2020 3:30:53 AM] Host lock lease acquired by instance ID '000000000000000000000000B1FC0ED8'.
[7/31/2020 3:32:36 AM] Executing HTTP request: {
[7/31/2020 3:32:36 AM] "requestId": "425ae07f-7bb8-4c54-beb7-d0c1eb43b6ba",
[7/31/2020 3:32:36 AM] "method": "GET",
[7/31/2020 3:32:36 AM] "uri": "/api/action-info-docs/get-one/asdfasdfasdfasdf"
[7/31/2020 3:32:36 AM] }
[7/31/2020 3:32:37 AM] Executing 'GetActionInfoDocOrchestration_HttpStart' (Reason='This function was programmatically called via the host APIs.',
Id=c67317dd-3f7e-4eab-89ef-2d3bfe155597)
[7/31/2020 3:32:37 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' scheduled. Reason: NewInstance. IsReplay: False. State: Scheduled. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 2.
[7/31/2020 3:32:59 AM] Started GetActionInfoDocOrchestration orchestration with ID = 'c3879f9bdd5f4665952b319a48b81eb7'.
[7/31/2020 3:32:59 AM] Executing 'GetActionInfoDocOrchestration' (Reason='', Id=7d29ec59-3cf6-467b-8cd3-a0d50d2b8eb4)
[7/31/2020 3:32:59 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' started. IsReplay: False. Input: (72 bytes). State: Started. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 3.
[7/31/2020 3:32:59 AM] Running GetActionInfoDocOrchestration.
[7/31/2020 3:32:59 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' completed. ContinuedAsNew: False.
IsReplay: False. Output: (48 bytes). State: Completed. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber:
4.
[7/31/2020 3:32:59 AM] Executed 'GetActionInfoDocOrchestration' (Succeeded, Id=7d29ec59-3cf6-467b-8cd3-a0d50d2b8eb4)
Stack overflow.
此时工作线程因 Stack Overflow
异常而暂停。调用栈包含大量类似这样的异常
编辑#2
编辑#3
Http 触发器代码(该函数接受一个名为 docuemntId 的字符串参数)
[FunctionName(THIS_ORCHESTRATION + "_HttpStart")]
public async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "action-info-docs/get-one/{documentId}")] HttpRequestMessage req,
[DurableClient] IDurableOrchestrationClient starter,
string documentId, ILogger log)
{
string instanceId = await starter.StartNewAsync(THIS_ORCHESTRATION, null, documentId);
log.LogInformation($"Started {THIS_ORCHESTRATION} orchestration with ID = '{instanceId}'.");
DurableOrchestrationStatus status;
while (true)
{
status = await starter.GetStatusAsync(instanceId);
if (status.RuntimeStatus == OrchestrationRuntimeStatus.Completed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Failed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
{
break;
}
}
return req.CreateResponse(System.Net.HttpStatusCode.OK, status.Output);
}
编辑#4
如下所示,我更改了我从 [DurableClient] IDurableOrchestrationClient starter
[DurableClient] IDurableClient starter
调用的编排的 Http 触发器。这个项目还有五个编排我没改。
在 Stack Overflow
消息之后,调试会话终止后我还收到以下消息:
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'func host start'" terminated with exit code: 233.
编辑#5
我确实将我的函数项目中的所有六个编排从 IDurableOrchestrationClient
更改为 IDurableClient
。仍然得到同样的错误。
能否将 [DurableClient] IDurableOrchestrationClient starter 更改为 [DurableClient] IDurableClient starter 并试一试?
原来问题出在编排的HttpStart
函数中的这段代码:
DurableOrchestrationStatus status;
while (true)
{
status = await starter.GetStatusAsync(instanceId);
if (status.RuntimeStatus == OrchestrationRuntimeStatus.Completed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Failed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
{
break;
}
}
return req.CreateResponse(System.Net.HttpStatusCode.OK, status.Output);
在我用
替换上面的代码后,Stack Overflow
异常消失了
return await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req, instanceId);
visual-studio-code
azure-functions
vscode-debugger
azure-functions-core-tools
azure-durable-functions
使用
在本地开发一堆 Azure 函数- Windows 10 个 64 位
- Visual Studio代码
- C#/.NET 核心
一切都很好。我能够在本地开发和调试我的 Azure 函数,然后将它们部署到 Azure。然而一天前,我从 netcoreapp2.2
升级到 netcorepp3.1
。这是我目前的 settings.json
{
"azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish",
"azureFunctions.templateFilter": "Verified"
}
现在我仍然可以通过按 F5
启动本地调试会话。但是当我尝试对 localhost:7071
API 地址发出 http 请求时,调试器会话终止并显示以下消息:
...
[7/30/2020 8:21:32 PM] f4f4622abc054ed29ac69f1210a204a8: Function 'GetScorecardsByActionTargetType (Orchestrator)' completed. ContinuedAsNew: False. IsReplay: False. Output: (332 bytes). State: Completed. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 8.
[7/30/2020 8:21:32 PM] Executed 'GetScorecardsByActionTargetType' (Succeeded, Id=11f2a673-851e-4afb-9ed6-81f6e3eefc8d)
Stack overflow.
/d/Users/xxx/AppData/Roaming/npm/func: line 14: 2125 Segmentation fault node "$basedir/node_modules/azure-functions-core-tools/lib/main.js" "$@"
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'func host start'" terminated with exit code: 139.
关于升级过程中发生什么问题的任何想法(我假设升级是导致它的原因)?
编辑:
我注释掉了我正在处理的新功能(编排)。相反,我尝试在调试器中 运行 升级之前使用的旧编排之一,我没有改变。这个旧函数与新函数在同一个本地函数项目中。
这里是终端 Window 抄本:
[7/31/2020 3:30:48 AM] Task hub worker started. Latency: 00:00:02.1744949. InstanceId: . Function: . HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 1.
[7/31/2020 3:30:48 AM] Host started (2892ms)
[7/31/2020 3:30:48 AM] Job host started
Hosting environment: Production
Content root path: D:\Users\xxx\Documents\VisSources\PolTrackCosmosDbFunctions\bin\Debug\netcoreapp3.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[7/31/2020 3:30:53 AM] Host lock lease acquired by instance ID '000000000000000000000000B1FC0ED8'.
[7/31/2020 3:32:36 AM] Executing HTTP request: {
[7/31/2020 3:32:36 AM] "requestId": "425ae07f-7bb8-4c54-beb7-d0c1eb43b6ba",
[7/31/2020 3:32:36 AM] "method": "GET",
[7/31/2020 3:32:36 AM] "uri": "/api/action-info-docs/get-one/asdfasdfasdfasdf"
[7/31/2020 3:32:36 AM] }
[7/31/2020 3:32:37 AM] Executing 'GetActionInfoDocOrchestration_HttpStart' (Reason='This function was programmatically called via the host APIs.',
Id=c67317dd-3f7e-4eab-89ef-2d3bfe155597)
[7/31/2020 3:32:37 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' scheduled. Reason: NewInstance. IsReplay: False. State: Scheduled. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 2.
[7/31/2020 3:32:59 AM] Started GetActionInfoDocOrchestration orchestration with ID = 'c3879f9bdd5f4665952b319a48b81eb7'.
[7/31/2020 3:32:59 AM] Executing 'GetActionInfoDocOrchestration' (Reason='', Id=7d29ec59-3cf6-467b-8cd3-a0d50d2b8eb4)
[7/31/2020 3:32:59 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' started. IsReplay: False. Input: (72 bytes). State: Started. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber: 3.
[7/31/2020 3:32:59 AM] Running GetActionInfoDocOrchestration.
[7/31/2020 3:32:59 AM] c3879f9bdd5f4665952b319a48b81eb7: Function 'GetActionInfoDocOrchestration (Orchestrator)' completed. ContinuedAsNew: False.
IsReplay: False. Output: (48 bytes). State: Completed. HubName: PolTrackTestHubV5. AppName: . SlotName: . ExtensionVersion: 2.2.2. SequenceNumber:
4.
[7/31/2020 3:32:59 AM] Executed 'GetActionInfoDocOrchestration' (Succeeded, Id=7d29ec59-3cf6-467b-8cd3-a0d50d2b8eb4)
Stack overflow.
此时工作线程因 Stack Overflow
异常而暂停。调用栈包含大量类似这样的异常
编辑#2
编辑#3
Http 触发器代码(该函数接受一个名为 docuemntId 的字符串参数)
[FunctionName(THIS_ORCHESTRATION + "_HttpStart")]
public async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "action-info-docs/get-one/{documentId}")] HttpRequestMessage req,
[DurableClient] IDurableOrchestrationClient starter,
string documentId, ILogger log)
{
string instanceId = await starter.StartNewAsync(THIS_ORCHESTRATION, null, documentId);
log.LogInformation($"Started {THIS_ORCHESTRATION} orchestration with ID = '{instanceId}'.");
DurableOrchestrationStatus status;
while (true)
{
status = await starter.GetStatusAsync(instanceId);
if (status.RuntimeStatus == OrchestrationRuntimeStatus.Completed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Failed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
{
break;
}
}
return req.CreateResponse(System.Net.HttpStatusCode.OK, status.Output);
}
编辑#4
如下所示,我更改了我从 [DurableClient] IDurableOrchestrationClient starter
[DurableClient] IDurableClient starter
调用的编排的 Http 触发器。这个项目还有五个编排我没改。
在 Stack Overflow
消息之后,调试会话终止后我还收到以下消息:
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'func host start'" terminated with exit code: 233.
编辑#5
我确实将我的函数项目中的所有六个编排从 IDurableOrchestrationClient
更改为 IDurableClient
。仍然得到同样的错误。
能否将 [DurableClient] IDurableOrchestrationClient starter 更改为 [DurableClient] IDurableClient starter 并试一试?
原来问题出在编排的HttpStart
函数中的这段代码:
DurableOrchestrationStatus status;
while (true)
{
status = await starter.GetStatusAsync(instanceId);
if (status.RuntimeStatus == OrchestrationRuntimeStatus.Completed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Failed ||
status.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
{
break;
}
}
return req.CreateResponse(System.Net.HttpStatusCode.OK, status.Output);
在我用
替换上面的代码后,Stack Overflow
异常消失了
return await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req, instanceId);