comp.lang.ada
 help / color / mirror / Atom feed
From: hreba <f_hreba@yahoo.com.br>
Subject: generic provokes segmentation fault
Date: Sun, 17 May 2020 16:19:05 +0200
Date: 2020-05-17T16:19:05+02:00	[thread overview]
Message-ID: <hicvepF6b7sU1@mid.individual.net> (raw)

Hi,

I'll try to describe the problem without posting loads of code. Still 
working on my thick binding of GSL/Odeiv2, the API of my package odeiv2 
consists of 3 procedures:
  - Init_Solve
  - Solve
  - Finit_solve
They basically copy values to variables which are global in odeiv, and 
pass their addresses to the C library functions of the thin binding. 
Example: Solve contains

status:= Gsl.gsl_odeiv2_driver_apply
	(solver.driver, solver.t1'Access, solver.t2,
	 solver.y(solver.y'First)'Access);

solver is a global record variable with components t1, t2 of type 
C.double, and solver.y of type

    type C_Array is array (Integer range <>) of aliased C.double;
    pragma Convention (C, C_Array);

The main program calls Init_Solve once, then Solve a hundred times, and 
finally Finit_Solve. It works and calculates the correct numbers. Now 
when I make odeiv generic:

generic
    dim:	Positive;
    type Float is digits<>;
package odeiv2 is
...

and substitute in the main program

    package Ode renames odeiv2;

with

    type Real is digits 6;
    package Ode is new odeiv2 (2, Real);

and change nothing else, I get a

raised STORAGE_ERROR : stack overflow or erroneous memory access
(SIGSEV, segmentation fault, when run under the debugger)
just at the line starting "status:= ..." shown above.
What would be an explication or a remedy for this behaviour?

-- 
Frank Hrebabetzky, Kronach	+49 / 9261 / 950 0565

             reply	other threads:[~2020-05-17 14:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 14:19 hreba [this message]
2020-05-17 17:51 ` generic provokes segmentation fault Dennis Lee Bieber
2020-05-17 18:34 ` Dmitry A. Kazakov
2020-05-18 11:29   ` hreba
2020-05-18 12:36     ` Dmitry A. Kazakov
2020-05-18 20:16       ` hreba
2020-05-18 21:30         ` Dmitry A. Kazakov
2020-05-17 21:02 ` Jeffrey R. Carter
2020-05-18 20:21   ` hreba
replies disabled

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