From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Can anyone help with GNAT.Perfect_Hash_Generators ? (Possible memory corruption) Date: Sun, 4 Sep 2016 19:22:00 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 4 Sep 2016 19:22:00 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="eab84d932a0f4c9d4606240766f0f5e7"; logging-data="10421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aVE9RWu5LR6wnF+Hizlxe" User-Agent: slrn/1.0.2 (FreeBSD) Cancel-Lock: sha1:VUydWU6PRHGLtGv8CEPSN6OPrFw= Xref: news.eternal-september.org comp.lang.ada:31703 Date: 2016-09-04T19:22:00+00:00 List-Id: 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