«Неинициализированное значение было создано выделением стека» с помощью NAG fortran 6.2 - PullRequest
0 голосов
/ 04 октября 2018

Я получаю очень странное поведение с последней версией компилятора NAG Fortran Release 6.2 (Chiyoda) Build 6214. При использовании ifort или gfortran все в порядке, и даже с компилятором NAG Fortran Release 6.1 (Tozai) Build 6136Следующий код воспроизводит ошибку, которую я получаю:

module mod
  type :: type1_t
  end type type1_t

  type :: type2_t
  contains
    procedure, nopass :: proc2
  end type type2_t
contains
  subroutine proc2
    class(type1_t), allocatable :: bug
  end subroutine proc2
end module mod

program main
  use mod
  type(type2_t) :: type2
  call type2 % proc2
end program main

В принципе, проблема, похоже, заключается в локальной переменной bug в процедуре proc2.Я получаю следующее сообщение об ошибке при использовании Valgrind:

==22467== ERROR SUMMARY: 26 errors from 9 contexts (suppressed: 0 from 0)
==22467== 
==22467== 1 errors in context 1 of 9:
==22467== Syscall param write(buf) points to uninitialised byte(s)
==22467==    at 0x5710154: write (write.c:27)
==22467==    by 0x568B1BC: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1203)
==22467==    by 0x568BB2E: new_do_write (fileops.c:457)
==22467==    by 0x568BB2E: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1277)
==22467==    by 0x567F2AE: fputs (iofputs.c:38)
==22467==    by 0x16E42B: write_insertion (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x16FFC7: rt_message_core.constprop.7 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x17163D: __NAGf90_rterr (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x121CD8: line_deallocate.isra.2 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x123E98: __NAGf90_laDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Address 0x1ffeffe969 is on thread 1's stack
==22467==  in frame #4, created by write_insertion (???:)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 2 of 9:
==22467== Conditional jump or move depends on uninitialised value(s)
==22467==    at 0x4C32CF9: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22467==    by 0x567F204: fputs (iofputs.c:33)
==22467==    by 0x16E42B: write_insertion (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x16FFC7: rt_message_core.constprop.7 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x17163D: __NAGf90_rterr (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x121CD8: line_deallocate.isra.2 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x123E98: __NAGf90_laDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 3 of 9:
==22467== Use of uninitialised value of size 8
==22467==    at 0x121C48: line_deallocate.isra.2 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x123E98: __NAGf90_laDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 4 of 9:
==22467== Conditional jump or move depends on uninitialised value(s)
==22467==    at 0x127C63: __NAGf90_cdangling_aDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 5 of 9:
==22467== Use of uninitialised value of size 8
==22467==    at 0x15FEA9: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 6 of 9:
==22467== Use of uninitialised value of size 8
==22467==    at 0x15FE96: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 1 errors in context 7 of 9:
==22467== Conditional jump or move depends on uninitialised value(s)
==22467==    at 0x15FE90: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 9 errors in context 8 of 9:
==22467== Conditional jump or move depends on uninitialised value(s)
==22467==    at 0x4C32D08: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22467==    by 0x567F204: fputs (iofputs.c:33)
==22467==    by 0x16E42B: write_insertion (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x16FFC7: rt_message_core.constprop.7 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x17163D: __NAGf90_rterr (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x121CD8: line_deallocate.isra.2 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x123E98: __NAGf90_laDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== 
==22467== 10 errors in context 9 of 9:
==22467== Conditional jump or move depends on uninitialised value(s)
==22467==    at 0x16EAD1: write_insertion (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x16FFC7: rt_message_core.constprop.7 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x17163D: __NAGf90_rterr (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x121CD8: line_deallocate.isra.2 (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x123E98: __NAGf90_laDeAlloc (in /home/rcarvalho/Desktop/nagdebug/a.out)
==22467==    by 0x15FEDB: mod_MP_proc2 (test.f90:12)
==22467==    by 0x15FF54: main (test.f90:18)
==22467==  Uninitialised value was created by a stack allocation
==22467==    at 0x15FBA4: mod_MP_proc2 (test.f90:10)
==22467== 
==22467== ERROR SUMMARY: 26 errors from 9 contexts (suppressed: 0 from 0)
Aborted (core dumped)

Есть какие-либо предложения в понимании этого поведения?Или, возможно, я делаю что-то не так ...

1 Ответ

0 голосов
/ 06 октября 2018

Очевидно, что эта проблема уже была решена в патче 6218, как «возможный сбой во время выполнения для локального полиморфного скаляра, выделяемого без параметров типа, если локальная переменная не была выделена в какое-то время во время выполнения подпрограммы.»

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...