comp.lang.ada
 help / color / mirror / Atom feed
* Can anyone help with GNAT.Perfect_Hash_Generators ? (Possible memory corruption)
@ 2016-09-04 19:22 Natasha Kerensikova
  2016-09-05 17:18 ` Stephen Leake
  0 siblings, 1 reply; 16+ messages in thread
From: Natasha Kerensikova @ 2016-09-04 19:22 UTC (permalink / raw)


Hello,

I'm afraid this is a bit off-topic, since I'm asking about a package
provided with GNAT rather than Ada language, I'm very lost and would
greatly appreciate any hint or help to work around it.

So I'm using GNAT.Perfect_Hash_Generators in two different programs, but
with the same sequence of calls : 254 times Insert, then Initialize and
Compute. The problem already shows at this point, even though I loop
around retrying with different seeds and/or more vertices.

In one of the program, everything works fine. In the second program, it
doesn't seem to terminate. But turning on the verbose mode, it appears
that one of the keys gets corrupted.

Looking at the verbose log generated by GNAT.Perfect_Hash_Generators,
the sequence of "Inserting" is identical, then the "Initial Key Table"
looks fine, then there is the first line that differs in both runs,
"Selecting position 1 results in 35 differences", when it works, while
it finds 36 differences when it doesn't. And I can confirm that there are
only 35 different leading characters in this set of keys.

Then are sets of keys that I really can't interpret, but they are
slightly different.

And then there is the "Reduced Keys Table", after having selected the
position set (1, 2, 3, 4). So if I guess correctly, the reduced key
table is supposed to have the first four characters of the correspond
keys. And that is indeed the case, except for key #67, which is dumped
as seven NUL characters, when the original key was "http://" and when it
works it is reduced to "http".

So at this point, my guess is that somehow something corrupts the key
table, and my key #67 gets turned into a lot of NUL characters, and
that's how it counts 36 different leading characters.

Now one of the reasons I like Ada so much is that under normal
circumstances it's impossible to corrupt memory, especially in a way
that depends on what other code is compiled besides it. So I'm pretty
much at loss when trying to debug it, especially in code I haven't
written using a complex algorithm on which I have no clue.

So is there anybody who can help with it? Or give me any clue?
Should I offer the verbose log, the source code, some other info?

Or should I just consider myself lucky when a GNAT.* package works, and
find some other solution when they don't?


Thanks in advance for your help,
Natasha


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-09-09  8:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-04 19:22 Can anyone help with GNAT.Perfect_Hash_Generators ? (Possible memory corruption) Natasha Kerensikova
2016-09-05 17:18 ` Stephen Leake
2016-09-06 19:24   ` Natasha Kerensikova
2016-09-06 19:52     ` Florian Weimer
2016-09-06 20:55       ` Jeffrey R. Carter
2016-09-06 21:04       ` Simon Wright
2016-09-08 16:00         ` Anh Vo
2016-09-08 17:04           ` Simon Wright
2016-09-08 18:03             ` Anh Vo
2016-09-08 18:10               ` Simon Wright
2016-09-08 19:08               ` Jeffrey R. Carter
2016-09-09  6:04                 ` Natasha Kerensikova
2016-09-09  6:15                   ` Jeffrey R. Carter
2016-09-09  8:25                   ` J-P. Rosen
2016-09-08 19:19       ` Florian Weimer
2016-09-06 19:44   ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox