szaghi / FLAP

Fortran command Line Arguments Parser for poor people
151 stars 34 forks source link

Potential BUG in FLAP (varying size parameters) #48

Closed victorsndvg closed 9 years ago

victorsndvg commented 9 years ago

Hi Stefano,

we believe that we detected a BUG in FLAP. It is related to the management of (not required) varying size command-line parameters with a specified default value. In particular, the BUG is revealed whenever no value is specified thorough the command line. The code snippet (see the gist link) reproduces the BUG. When executing the program with no arguments, then the following error from the runtime system is obtained (We used the Intel compiler version 15.0.2.):

forrtl: severe (408): fort: (7): Attempt to use pointer VAL when it is not associated with a target

Image PC Routine Line Source test_flap 00000000005EBDD0 Unknown Unknown Unknown test_flap 000000000046450D data_type_command 1086 Data_Type_Command_Line_Interface.F90 test_flap 000000000058AB72 data_type_command 3030 Data_Type_Command_Line_Interface.F90 test_flap 0000000000406072 MAIN__ 47 test_flap.f90 test_flap 000000000040439E Unknown Unknown Unknown libc.so.6 00007F0BC952C76D Unknown Unknown Unknown test_flap 0000000000404289 Unknown Unknown Unknown

You can find the test program we have used in the following gist link: https://gist.github.com/victorsndvg/39b86ab888fec8d27bbd#file-test_flap_varying_size-f90

I think that the problem is that cla%val is not allocated at the following line: https://github.com/szaghi/FLAP/blob/master/src/Data_Type_Command_Line_Interface.F90#L1093

A workaround that we are using is to add:

if (present(def )) cla%val = def

inside the add subroutine at the following line: https://github.com/szaghi/FLAP/blob/master/src/Data_Type_Command_Line_Interface.F90#L2317

What do you think?

Best regards, Víctor.

szaghi commented 9 years ago

Hi victor, I am sorry, but I am out of office for 2 weeks, thus I cannot check the details of the bug. It seems really a bug and your patch is nice, please make a pull request thus I can easily accept it to fix the bug, with my smartphone/tablet I can only interact by means of github :-(

szaghi commented 9 years ago

Added the workaround.