We have been using Hydra successfully in our Delphi applications to display various visual plugins and up until now, we had no specific issues.
However, as we start using Hydra in 64 bits applications with high memory usage, we observe frequent crashes that prove very difficult to reproduce.
After lengthy investigations, we could not pinpoint the issue but we discovered a very troubling code inside
RemObjects.Hydra.WPF\VisualPlugin.pas, more precisely, the
Indeed, its return type is set as
Int32 but it reads the value from
Control.Handle which is a
IntPtr and we know from past experience that this is the source of many elusive bugs.
That’s because on a 32bits application, or a very lightly loaded 64bits one, the handle values given by the OS never grow out of the
But in moderately to heavily loaded systems, the handle values can be bigger than
Int32 and casting them to them leads to truncation, in turn leading to corrupting every possible things it touches.
Int32 inside Hydra code gives many usages, most of which appear legitimate, but all of them should be reviewed and clearly, the
GetHandle methods should have their signatures changed to use
Just for testing, how can we recompile the Hydra sources?