Segmentation error opening file in ADA

I need to port some legacy software written in ADA from Windows to Linux. The program compiles fine, but ends with a segmentation error on execution.

Segfault occurs when a program tries to open a file (file exists;). Oddly enough, the program manages to open another file earlier when executed without errors. Both files are binary files.

By executing the program with gdb, I could track the last line executed with

DIO.Open (FP (File), To_FCB (Mode), Name, Form); 

which is defined in line a-direio.adb, line 167.

How can I continue to investigate the cause of the malfunction? The parameter values ​​for DIO.Open look OK (they are similar to the previous successful call to DIO.Open, except for the file name). Any hints are welcome.


Edit

Here is the code that ultimately calls DIO.Open:

 procedure Open (The_File : in out File_Type; The_Mode : in A_DB_Mode := DBS_Database_Types.InOut_DB; The_Name : in String; The_Form : in String := "") is begin Ada_File_IO.Open (File => The_File, Mode => DB_Mode_To_File_Mode(The_Mode), Name => The_Name, Form => The_Form); exception when Ada_File_IO.Status_Error => raise Status_Error; when Ada_File_IO.Name_Error => raise Name_Error; when Ada_File_IO.Use_Error => raise Use_Error; end Open; 

where ADA_File_IO is declared as

 package Ada_File_IO is new Ada.Direct_IO(Element_Type => GNL_Universal_Representation.An_Item); 

GNL_Universal_Representation.An_Item allows

 subtype An_Item is GNL_Basic_Types.A_Byte; type A_Byte is mod 2**Byte_Size; 

and DB_Mode_To_File_Mode (The_Mode) allows Ada_File_IO.In_File.


Edit (2)

This is gdb output with some file names (as suggested by Brian)

 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb563db40 (LWP 9887)] 0x081053af in system.file_io.open () (gdb) bt #0 0x081053af in system.file_io.open () #1 0x080fd447 in system.direct_io.open () #2 0x08066182 in dbs_file.ada_file_io.open (file=0x0, mode=in_file, name=..., form=...) at /media/chmiwah/ADA/lib/gcc/i686-pc-linux-gnu/4.7.4/adainclude/a-direio.adb:167 #3 0x080665cc in dbs_file.open (the_file=0x0, the_mode=in_db, the_name=..., the_form=...) at /media/chmiwah/GISMO/bbp-benchmark/code/rebsys/src/dbs/ntv/bdy/dbs_file.adb:108 #4 0x080631b0 in dbs_database.open (the_database=0xb5500468, the_mode=in_db, the_name=..., the_form=..., using_the_definition=0xb5646008) at /media/chmiwah/GISMO/bbp-benchmark/code/rebsys/src/dbs/gnc/bdy/dbs_database.adb:363 
+6
source share
1 answer

I see that you are using a multi-threaded program. When using gdb, note that "bt" will not be terribly useful as it only shows one stream (I cannot remember if it is the main stream or the current stream).

Use the following instead:

 thread apply all bt 

or

 thread apply all bt full 

In addition, using strace -f -e trace=file your_program args will be useful to determine if an error will occur before or after a system call to open.

It would be very useful to know which version of the compiler you are using, and what parameters were used to create it (especially if any warnings were disabled).

Is the file name encoding more or less US-ASCII?

+1
source

All Articles