Closed LeifEirik closed 7 months ago
Hi @LeifEirik. An AV at the end block hints something related to interface reference counting, i.e., an object implementing an interface is being destroyed. That's my guess but it's hard to know for now.
Can you please put a breakpoint in the TBasicAWSCredentials.Destroy
and check if it executes twice and, if yes, the call stack you get at both moments?
Hi @wlandgraf ,
Unsure if the TBasicAWSCredentials.Destroy executes twice, the AV occurs the first time it is executed.
How to reproduce: An easy way to see the error is to use a TMS xData demo project that comes with xData/Aurelius:
uses ...., AWS.SNS, AWS.SNS.Client;
procedure TApiServerModule.ameMainInserting(Sender: TObject; Args: TInsertingArgs); const AWS_ACCESS_KEY = 'Your_Access_Key_Here'; AWS_SECRET_KEY = 'Your_Secrey_Key_Here'; var AWSClient: IAmazonSimpleNotificationService; begin { CREATE AWS SNS Topic } AWSClient := TAmazonSimpleNotificationServiceClient.Create(AWS_ACCESS_KEY, AWS_SECRET_KEY); AWSClient.CreateTopic('NEW_TOPIC_FOR_TEST').TopicArn; end;
Thanks for the detailed response, @LeifEirik. But, unfortunately, I cannot reproduce it. Everything works just fine here. I have tested it in both Delphi 11 and Delphi 10.4.2. Have you applied all updates to your Delphi? The 10.4.2 version I'm testing is 27.0.40680.4203.
Hi Wagner,
Using the SNS with Delphi 10.4.2, TMS xData 5.5.0.0, Aurelius 5.8.0.0 I have come across an AV that I'm unable to work around. I might be wrong, but to me it seems to only happen when used on xData Rest server for some strange reason.
If I run this code on new Delphi vcl project, all works as expected:
AWSClient: IAmazonSimpleNotificationService; lAWSTopicARN: string; begin { CREATE AWS SNS Topic } AWSClient := TAmazonSimpleNotificationServiceClient.Create(AWS_ACCESS_KEY, AWS_SECRET_KEY); lAWSTopic.Arn := AWSClient.CreateTopic('NEW_TOPIC_FOR_TEST').TopicArn; end;
...but if done on my rest server if gives me an AV. On my rest server I have a model where one entity is TAWSTopic, and I use the TAureliusModelEvents component and have implemented the OnInserting event as below:
{ Inserting } procedure TAppModelEvents.ameMainInserting(Sender: TObject; Args: TInsertingArgs); var lAWSTopic: TAWSTopic; AWSClient: IAmazonSimpleNotificationService; lAWSTopicARN: string;
begin if Args.Entity is TAWSTopic then begin lAWSTopic := TAWSTopic(Args.Entity);
end; end;
Now if I debug from the very last "end;" for the event implementation, and just do F7 until AV, I get to the file AWS.RunTime.Credentials, and at the exit of destructor TBasicAWSCredentials.Destroy I get an AV.
destructor TBasicAWSCredentials.Destroy; begin inherited; end; <---- At the exit of this is where I get the AV