

chkaufmann
-
Content Count
167 -
Joined
-
Last visited
Posts posted by chkaufmann
-
-
22 minutes ago, Lars Fosdal said:That FFFFFFF9 address looks like a nil reference negative offset.
Does TBSDictionary.SetElements check the validity of the references?
No, there is no such check in SetElements. In this case here, these are persistent objects. But I added a TMonitor.Enter / Leave arround the access of TBSDictionary/TDictionary since the code runs in an application with multiple threads and it may happen, that two threads run the method GetBasispunkt for the same object at the same time. Since the error is not reproducable, this may solve the problem.
-
I have an error in my application. It happens from time to time on my server, but I cannot reproduce it.
The call stack from madExcept looks like this:
exception number : 1 exception class : EAccessViolation exception message : Access violation at address 0040BB2E in module 'Logo12RestAPI.exe'. Read of address FFFFFFF9. thread $1b78 (TIdThreadWithTask): 0040bb2e Logo12RestAPI.exe System 22 @UStrAsg 022e67aa Logo12RestAPI.exe geoRefBOImp 60 {System.Generics.Collections}TDictionary<System.string,mainBO.IBasispunkt>.DoAdd 022e7303 Logo12RestAPI.exe geoRefBOImp 60 {System.Generics.Collections}TDictionary<System.string,mainBO.IBasispunkt>.AddOrSetValue 022e5e1f Logo12RestAPI.exe geoRefBOImp 1580 {BSCollectionsImp}TBSDictionary<System.string,mainBO.IBasispunkt>.SetElements 022d5fa5 Logo12RestAPI.exe geoRefBOImp 1586 TLocation.GetBasispunkt 022d7cff Logo12RestAPI.exe geoRefBOImp 1890 TLocation.Ukm 00411300 Logo12RestAPI.exe System 22 @IntfClear 00411321 Logo12RestAPI.exe System 22 @IntfCopy 00411300 Logo12RestAPI.exe System 22 @IntfClear 02847e35 Logo12RestAPI.exe restAPIServer 1306 TRestAPIGetEntities.Basispunkte
Can anybody give me a hint, where the problem could be located? I work with Delphi 11, Version 28.0.44500.8973.
Christian
-
private and protected are "friends" for classes within the same unit. If you don't want that, use "strict private" and "strict protected".
For your second problem, you should provide an example. It is not clear to me what doesn't work.
And by the way: When you write questions like this in a forum where most of the answers come from volunteers, you probably end up on the ignore list of many of them.
Regards
Christian-
1
-
-
39 minutes ago, Attila Kovacs said:r := AWorkItem.Result.ToRecord<TPrepareesult>;
oops, that's embarrassing, thanks!
Christian
-
I define a BackgroundWorker like this:
FUIWorker := Parallel.BackgroundWorker; FUIWorker .Execute( procedure(const AWorkItem: IOmniWorkItem) var p : TPrepareAusfuehrungen; r : TPrepareResult; begin p := TPrepareAusfuehrungen.Create(AWorkItem.Data.ToRecord<TPrepareSettings>); try r := p.Execute(AWorkItem.CancellationToken); if not AWorkItem.CancellationToken.IsSignalled then AWorkItem.Result := TOmniValue.FromRecord<TPrepareResult>(r); finally p.Free; end; end) .OnRequestDone( procedure(const ASender: IOmniBackgroundWorker; const AWorkItem: IOmniWorkItem) var r : TPrepareResult; begin r := AWorkItem.Data.ToRecord<TPrepareResult>; ...... end);
This fails in OnRequestDone with an AV. When I change it so that the result value is just an IInterface it works.
So my question is, how can I make it work with a "record" result? Or should I always create an interfaced object for this?
Christian
-
Hi,
I have to log each POST request to my TIdHTTPServer to a file. When I look at TIdHttpRequestInfo I don't find a property with the full data sent to my server.
Do I have to combine RawHeaders and PostStream in order to get the full request?
Is there something else, where data is written to?
Is there a method I didn't see in order to get all this information in one block?Regards
Christian -
I use ExitProcess(AExitCode).
Christian
-
3 hours ago, dummzeuch said:This sounds like it might be what you want:
https://www.peganza.com/PALHelp/index.html?identifiers_report.htm
Thanks, good idea. I forgot that one.
-
1 hour ago, dummzeuch said:You could rename or comment out that property and let the compiler find all the errors.
This is a solution, but I have too many places where I use the property. So this is not an option in this case.
-
In my interface I have the following property:
IBSEntityProvider = interface function GetItems(AItemId: Integer): IBSEntity; property Items[AItemId: Integer]: IBSEntity read GetItems; default; end;
Now I need to know, where this is used in my application. For a method I can use grep or, if the method has a common name, I put a "deprecated" in the method declaration and use the list of warnings. In this case here, it doesn't work. But maybe somebody has another trick for this problem.
Christian
-
You may add debug messages in your code (see OutputDebugString).
Personally I wrote a wrapper arround this method and with each call I add an id. At the start of my application I set a list of ids and then only messages with these ids are sent to the event log:
procedure TBSDebug.Message(const AMessage: String; ALogId: Integer); begin if FLogIds.Contains(ALogId) then OutputDebugString(PChar(AMessage)); end;
Christian
-
I could isolate the problem a bit more. Basically it happens when I try to destroy the TEdgeBrowser component during the time when the ICoreWebView2 object is in creation process. This runs async and the message when the setup has finished comes to late.
Now my quick and dirty solution before I destroy my TEdgebrowser is this:
while (Browser.BrowserControlState = TCustomEdgeBrowser.TBrowserControlState.Creating) do Application.ProcessMessages; Browser.Free;
It works, but I don't like it since there are a lot of things that may happen in ProcessMessages.
I cannot post the whole code since this is an interaction between two components in an application at very different places. I try to describe it.
- I have two TVirtualTree controls, one to navigate the objects, the other to edit attributes.
- When the inplace editor for an URL is closed, I call Browser.Navigate with the new URL
- When the user changes to a different object (click in the tree for navigation), the Browser will be destroy because this object may not need a browser.
- Now the click in the object tree triggers an EndEdit in the edit tree (causes Browser.Navigate) in a moment when the object change process didn't start yet
I was thinking of creating a delayed Navigate method in the Browser using a special message so I post that message in the queue. So the Navigate will not happen before the object change click message has finished.
Regards
Christian -
In my application I get this error:
exception class : EAccessViolation exception message : Access violation at address 035CD729 in module 'Logo12.exe'. Read of address 00000000. thread $343c: 035cd729 +0d Logo12.exe Vcl.Edge 1679 +1 TCustomEdgeBrowser.ProcessHResult 035cc712 +52 Logo12.exe Vcl.Edge 1028 +2 TCustomEdgeBrowser.CreateCoreWebView2ControllerCompleted 035d03e9 +11 Logo12.exe Vcl.Edge 828 +1 {Vcl.Edge}Callback`2.CreateAs[3]$ActRec<System.HRESULT,Winapi.WebView2.ICoreWebView2Controller,Winapi.WebView2.ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>.$0$Body 75725c2b +0b user32.dll DispatchMessageW 006cb497 +f3 Logo12.exe Vcl.Forms 11336 +23 TApplication.ProcessMessage 006cb4da +0a Logo12.exe Vcl.Forms 11366 +1 TApplication.HandleMessage 006cb819 +d1 Logo12.exe Vcl.Forms 11505 +27 TApplication.Run
Depending on the displayed data I create controls dynamically and for me this looks like my TEdgeBrowser control gets a message after it was already destroyed.
How can I ensure this doesn't happen? I tried to call Stop and the CloseBrowserProcess methods, but both don't work.
Christian
-
I recompiled the application with Sydney and now I get the same error with the customers server. Here is the full log:
Stat Connected. Recv 21.11.2022 20:49:55: 220 Microsoft FTP Service<EOL> Sent 21.11.2022 20:49:55: HOST 1.1.1.1<EOL> Recv 21.11.2022 20:49:55: 504 Server cannot accept argument.<EOL> Sent 21.11.2022 20:49:55: USER testftp<EOL> Recv 21.11.2022 20:49:56: 331 Password required<EOL> Sent 21.11.2022 20:49:56: PASS ********<EOL> Recv 21.11.2022 20:49:56: 230 User logged in.<EOL> Sent 21.11.2022 20:49:56: FEAT<EOL> Recv 21.11.2022 20:49:56: 211-Extended features supported:<EOL> LANG EN*<EOL> UTF8<EOL> AUTH TLS;TLS-C;SSL;TLS-P;<EOL> PBSZ<EOL> PROT C;P;<EOL> CCC<EOL> HOST<EOL> SIZE<EOL> MDTM<EOL> REST STREAM<EOL>211 END<EOL> Sent 21.11.2022 20:49:56: OPTS UTF8 ON<EOL> Recv 21.11.2022 20:49:56: 200 OPTS UTF8 command successful - UTF8 encoding now ON.<EOL> Sent 21.11.2022 20:49:56: TYPE I<EOL> Recv 21.11.2022 20:49:56: 200 Type set to I.<EOL> Sent 21.11.2022 20:49:56: SYST<EOL> Recv 21.11.2022 20:49:56: 215 Windows_NT<EOL> Sent 21.11.2022 20:49:56: TYPE I<EOL> Recv 21.11.2022 20:49:56: 200 Type set to I.<EOL> Sent 21.11.2022 20:49:56: CWD /testsplash<EOL> Recv 21.11.2022 20:49:56: 250 CWD command successful.<EOL> Sent 21.11.2022 20:49:56: PASV<EOL> Recv 21.11.2022 20:49:56: 227 Entering Passive Mode (10,0,19,1,240,228).<EOL> Sent 21.11.2022 20:49:56: STOR MM_LiveResultFtpTest.txt<EOL> Recv 21.11.2022 20:50:17: 150 Opening BINARY mode data connection.<EOL> Stat Disconnected.
In InternalPut it runs fine until the call LPasvCl.Connect; Then there is a timeout and the upload fails. When I use Filezilla I get the same message, but for some reason the upload works in a second try:
Command: STOR meet_live_ftp_Fail_Sydney.log Response: 150 Opening BINARY mode data connection. Error: Connection timed out after 20 seconds of inactivity Error: File transfer failed Status: Connecting to 91.217.122.30:21... Status: Connection established, waiting for welcome message... Status: Plain FTP is insecure. Please switch to FTP over TLS. Status: Logged in Status: Retrieving directory listing of "/testsplash"... Status: Directory listing of "/testsplash" successful
Now it's always difficult to explain to a customer, that this is a server side problem. So I would like to have a solution, that could handle this kind of problems like Filezilla.
Regards
Christian -
20 minutes ago, Fr0sT.Brutal said:Enable the most detailed logs as possible.
Is the error constant or random? Is TLS involded?
They use plain FTP.
And about logging, maybe a stupid question: Do I have to build this on my own? I can find the TIdLogBase / TIdLogFile classes, but I don't find examples where I can activate logging for FTP.
Christian
-
I use the Indy FTP client in my application. Since the update of the compiler to Alexandria 11, Update 1, one of my client gets the following error when the Put() command is called:
Opening BINARY mode data connection.
I have no idea, how I can fix that because I cannot reproduce it on FTP servers I work with.
The strange thing is, it worked fine as long as I compiled my application with Delphi Seattle.
Any hints?
Christian
-
19 hours ago, Fr0sT.Brutal said:If you absolutely trust your clients, you can send them server's timestamps to use. But I'd advice to store such info in the server itself.
I was thinking of something like that. Get the server timestamp and then keep the difference in the application.
But why could it be dangerous to send the server timestamp in an API Request?
Christian
-
1
-
-
Hi,
for my REST Api I create a key with timestamp in the client application. On the server I check if the key is valid and if it's not expired.
The problem here seems to be, that some client computers, who send valid requests, don't have the clock correctly set and I have differences of several minutes in the timestamps.
Should I allow a bigger differences for expiration times? Right now I test with 30 seconds.
Or is there another trick to solve this problem?
Regards
Christian -
4 hours ago, Fr0sT.Brutal said:I'd say your numbers are ridiculously small for any modern DB. 1M records per day is nothing.
Yes, for logging this is not a problem. But if I want to add limits to number of requests I have to check all four values. This means four SQL select on the log table for each request and this is not cheap anymore because most of the REST responses I build with data from objects already kept in memory.
Therefore I need an in memory data structure with this info for each user.
-
I run a Rest API and I need to monitor the number of requests per user in different intervals (5sec, 1min, 1hour, 1day).
Before I try to build my own structure, is there a common way to do this?
Since there may be several 100 users online at the same time, using a log table and an SQL database is not an option (too slow). And keeping a list of all requests of the last 24 hours in memory isn't either because there are some users with several 10'000 requests per day.
Regards
Christian -
2 hours ago, FPiette said:Why do you think you need 64-bit application? Do you have memory size issue (Like very large images to process)?
I have no memory issues anymore since I solved these with other changes in the code.
Maybe I'm too old, but personally I think, because there is need to change I would stay with 32bit.
But others in our team think we should change to 64bit because this is the technology of today. Therefore I try to collect objective arguments (pros and cons).
Christian
-
We are in the discussion if we should switch our application from 32bit to 64bit. Basically it seems to work fine under 64bit, however I'm not sure, if there may be some problems regarding resource usage.
Our main customer runs the application on an RDP Terminal Server. So my concern is, if this is relevant because a 64bit application always uses more RAM compared to the 32bit version.
Christian
-
And what about using a TLightweightMREW for each of my objects compared to TMonitor and Spring.Lock?
I probably need this to have a reentrant version of the lock:
https://www.thedelphigeek.com/2021/02/readers-writ-47358-48721-45511-46172.htmlChristian
-
On 8/29/2022 at 7:34 PM, Remy Lebeau said:The extra bytes are for a hidden pointer to a System.TMonitor instance (not to be confused with Vcl.Forms.TMonitor). Every TObject instance has an optional TMonitor instance associated with it. The actual TMonitor instance is created the 1st time it is accessed, but the parent TObject's InstanceSize includes space for a pointer to the TMonitor instance.
AFAIK, yes.
Read the TMonitor documentation, and also see What is TMonitor in Delphi System unit good for?
You could, yes. You would simply call TMonitor.Enter(obj) and TMonitor.Exit(obj) where needed.
When I read https://www.delphitools.info/2013/06/06/tmonitor-vs-trtlcriticalsection/, then I should not use TMonitor. Is this still the case? Is there another simpler solution to lock an object in order to avoid that multiple threads change an internal value. Locktime will be very short and conflicts probably happen very rarely.
Verify certificate with TIdHTTP
in Indy
Posted
I use TIdHTTP to make REST requests to my server. In order to avoid that somebody can analyze the traffic between my application and the server I would like to verify the certificate.
Right now my code looks like this:
sslIO := TIdSSLIOHandlerSocketOpenSSL.Create(Self); sslIO.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; sslIO.SSLOptions.Mode := sslmUnassigned; sslIO.SSLOptions.VerifyMode := []; sslIO.SSLOptions.VerifyDepth := 0; FHttp.IOHandler := sslIO;
I found some examples and tried to add an OnVerifyPeer event. But this event is never called. Are there any more options I have to set? Can somebody point me to a working example?
Thanks
Regards
Christian