I am attempting to call an exe with Azure Functions, and it was failing with Error Code 216. Another exe works fine.
Both executables are compiled with Delphi, and I had access to the source code for both. After a few debugging attempts I found that if I comment out FastMM4 in the uses block the exe that was returning Error Code 216 works.
So to make this a question why would fastmm4 cause an error 216 in Azure Functions?
I'm adding the minimum code to reproduce the error
Delphi Code:
program test;
{$D+,L+}
uses
FastMM4,
Windows,
Classes;
begin
Writeln('1');
end.
In the Azure Function: #r "Newtonsoft.Json"
using System.Diagnostics;
using System.Net;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log, ExecutionContext context)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
string responseMessage = Runexe();
return new OkObjectResult(responseMessage);
}
private static string Runexe() {
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "d:\\test.exe";
p.StartInfo.Arguments = "";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
output = p.StartInfo.FileName + " " + p.StartInfo.Arguments + "\r\n" + output;
return output;
}
Error in Azure is d:\home\test.exe Runtime error 216 at 00413D13