comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Interfaces.C + generics: stack overflow
Date: Sat, 25 Mar 2017 16:23:49 +0100
Date: 2017-03-25T16:23:49+01:00	[thread overview]
Message-ID: <ob6226$krf$1@gioia.aioe.org> (raw)
In-Reply-To: ejncfbF83u9U1@mid.individual.net

On 2017-03-25 15:17, hreba wrote:
> On 03/24/2017 11:03 PM, Dmitry A. Kazakov wrote:
>
> Thanks for your convincing suggestions and the detailed code. I changed
> my program accordingly - still STORAGE_ERROR.
>
> Then I followed the advice from Randy, transferring the exported
> function of the C library to another, non-generic package, changing the
> first parameter from
>
>    function gsl_integration_qng
>      (f: in out GSL_Function; ...
> to
>    function gsl_integration_qng
>      (f: System.Address; ...
>
> Result - STORAGE_ERROR

1. You could try to replace out T with access T. Especially because you 
apply a conversion to the argument.

2. You should also read the library documentation for memory allocation 
issues. Storage_Error is a usual result when an Ada allocated object is 
passed where a C malloc result expected. If some of the arguments are 
allocated by callee to be freed by the caller or conversely you must use 
Interfaces.C.Pointers to deal with these.

3. And you could debug it to get an idea where it fails. If the stack 
frame becomes corrupted, that means wrong call convention. An error in 
the heap indicates an allocator issue as above etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


      parent reply	other threads:[~2017-03-25 15:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23  7:43 Interfaces.C + generics: stack overflow hreba
2017-03-23  7:46 ` hreba
2017-03-23 17:45 ` Jeffrey R. Carter
2017-03-24 12:20   ` hreba
2017-03-23 20:03 ` Randy Brukardt
2017-03-24 12:42   ` hreba
2017-03-24 20:13     ` Randy Brukardt
2017-03-24 22:03     ` Dmitry A. Kazakov
2017-03-25 14:17       ` hreba
2017-03-25 15:21         ` hreba
2017-03-26 22:34           ` Robert Eachus
2017-03-27  7:21             ` Dmitry A. Kazakov
2017-03-30 17:12               ` Robert Eachus
2017-03-25 15:23         ` Dmitry A. Kazakov [this message]
replies disabled

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