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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1580f5833894f157 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.post.ch!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: program error (exception access violation) in windows Date: Wed, 27 Sep 2006 14:51:14 +0200 Organization: Swisscom IP+ (post doesn't reflect views of Swisscom) Message-ID: <451a73c2$1@news.post.ch> References: <1159312713.137314.324080@h48g2000cwc.googlegroups.com> NNTP-Posting-Host: 194.41.146.1 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: atlas.ip-plus.net 1159361477 29965 194.41.146.1 (27 Sep 2006 12:51:17 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Wed, 27 Sep 2006 12:51:17 +0000 (UTC) User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) In-Reply-To: <1159312713.137314.324080@h48g2000cwc.googlegroups.com> X-Original-NNTP-Posting-Host: w01iwt.pnet.ch X-Original-Trace: 27 Sep 2006 14:51:14 +0200, w01iwt.pnet.ch Xref: g2news2.google.com comp.lang.ada:6772 Date: 2006-09-27T14:51:14+02:00 List-Id: ldb schrieb: >> raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION > > We have tried, in numerous ways, to come up with an ada library that > can be used by c programs. The ada program needs to return a pretty > large and ugly dynamic structure. For the sake of discussion, think of > it as an array of structs (with pointers to dynamic sub-arrays). > > I've gotten it to work flawlessly under linux using shared libraries. I > use a combination of importing malloc() and the > Ada.Address_To_Access_Conversions package. In this way, I can malloc > the correctly sized eventual c data-structure, and use the created > access from that package to populate the data structure. When I return > the address of that to C, everything appears to work fine. I can free > it like any other C data structure. > > It seems to fail (sometimes) when I move it to windows (using a c > program and my ada-based dll), resulting in the above exception. When I > remove the free calls, in c, everything works fine (and memory leaks). > I have a 'minimal' program that uses a simple array of integers, and it > seems to work fine, but for our main program, it still crashes. > Tommorow, I'm going to rip apart our program to see if I can find a > minimal example of the crashing behavior. > > We've tried numerous different ways of allocating the memory in ada, > and free'ing it in C. We even got a smiliar error when we tried > allocating it in Ada, and free'ing it in Ada through another C call to > the ada library. We are about to change our interface from Ada to > single elements, only, and have C wrapper functions that do all the > allocating and query for each single value to populate the data > structure. > > Has anyone heard of issues like this? Or have a possible guess as to > what is going on? I once worked with C. Now I used gnat wich internaly uses malloc and free anyway. Still I went thrue the trouble of localising all the memory management on one side. Also I did not just provide a malloc and free c-likes but OO "contructors" and "destructors" constructs. Ok, you end up with lots of Xxxx_New and Xxxx_Delete functions but all worked fine in the end. Martin