-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory violation error compiling in Delphi 10.2 #83
Comments
You're not alone. I've been monitorizing that thread and tried to apply some workarounds from there, but with no luck. Something really weird is happening when using latest Delphi versions with current Fibplus. I've spent several hours with no luck. Sorry, |
@ruben-monmariola, if your Delphi version supports it, try disabling ASLR in linker options in both the Fibplus packages and your application project: |
Hi. I spent many hours trying to find something that would make sense of these errors and reviewing how FIBPlus allocates and frees memory, but I didn't find anything strange. I don't have those options that you mention in "linking". I'm still working with 32-bit versions. If you disable those options, does it no longer show the memory violation errors in 64-bit? |
Disabling ASLR related options made a difference in 32-bit. For sure the second one made no effect as it's for 64-bit only, but the first one removed some random access violation errors, mainly in OnValidate and OnChange, but unfornately not all of them. I'm using Delphi 12.1 Athens. Idea was found in this thread: https://en.delphipraxis.net/topic/6627-legacy-bad-code-issues-on-delphi-111-on-64bit-vcl-apps-related-to-new-aslr-linker-flags/. Later I found that there is a related issue, #60, also by @davideangeli, so maybe he could help us. Right now I've one repeteable, in This is too weird and low level for me to debug as seems like internals of Delphi are failing with this package. I'm going to try other compiler and linker options. Of course, any thoughts are welcome. |
Hi @did-vmonroig the issue #60 seems not closed but the changes that I made to solve it are already included in latest versions. The problem that you are experiencing in TFIBQuery.PreprocessSQL could they be related to the SQL query that you are running? Too complex, strange characters? Now in my applications I'm using fibPlus with Delphi 12.2 both 32bit and 64 bit connected to Firebird 5 databases and it is working pretty good. I've just done a couple of changes that I'll pull in a merge request but nothing so critical. |
Thanks for your help, @davideangeli. The query is as simple as this: SELECT MAX(NumeroOR)
FROM OrdenesReparacion
WHERE CodEmpresa = :CodEmpresa AND Ejercicio = :Ejercicio
AND Serie = :Serie Other more complicated queries run without this problem, but this is just an example. There is some kind of randomness in exceptions, difficult to reproduce them. So weird... Could be possible to take a look to your .dpk, .dpr an .dproj files? I still think there could be some compiler option differences, something related to pointers or record alignment, introducing these problems. Thanks in advance. |
@did-vmonroig if I simulate a similar query on my environment it works fine both 32/64 bits... To make some debug could be usefull a simple test case if reproducible. I compile the fibPlus units in a custom runtime package. If could help these are the bpl 64 bit compiling options: |
@davideangeli, thanks for providing your compiling options. There are some differences, like record field alignment or stack frames, but generating new DCU and BPL with your options made no difference. I'm trying to extract the simplest reproducible sample that always throws an exception. It's not easy as exceptions are thrown with some extrange randomness and there are some third party components involved. In fact, I've started using FastMM with full debug and now exceptions are thrown in different conditions and involve stack corruption. For example: Maybe this can lead to a new clue to more experienced developers. |
I've tried record field alingment in all its flavours, altough in @ruben-monmariola, may I know the third party components included in the project where you're using FibPlus? I would like to make a common list because our compiler version is not the same but the problems with random access violations are. If you prefer not disclosing that information here, we could talk about this privately. |
Mainly DevExpress and Indy. I also use madexcept. I tried disabling madexcept but the errors were the same. |
With help from FastMM4 and
Seems that in |
With I can't understand why few people finds this problem. Maybe is because Win32 implementation differs from Win64, or they are not using I'm testing a patch that solves in my end this problem and also #78. If it's stable I'll send a PR. |
I use many features of FibPlus. I have tried to migrate to Delphi 10.2 and it has been impossible. Simple Datamodules with TpIBQuery work correctly. Datamodules with TpIBDataSet that use OnValidate or OnChange in most cases I get memory violation errors. I have tried to debug the program but the errors do not make sense, but they always occur inside FIBPlus functions. There is not a single line of code where it fails. Sometimes it is in an AsString, calculating the pointer where to save the data in the TFIBStringField, other times it is when calling Open, accessing an internal TList of the TpFIBDataset component, sometimes it is in an OnCalcFields, in the internal DataEvent. The only forum I have seen where there are other people with the same problem is https://www.clubdelphi.com/foros/showthread.php?t=93687
The text was updated successfully, but these errors were encountered: