2017-03-29 20 views
2

현재 연구 중 일부로 Fortran90에서 불쾌한 편미분 방정식을위한 커다란 비선형 해를 작성했습니다. 나는 메모리 손상 문제가 내 코드를 괴롭 히고 있으며이를 추적하려고 시도하고 있다고 생각하는 문제에 직면 해있다. 그렇게하기 위해, 나는 valgrind를 사용하기로 결정했습니다. 이것은 valgrind가 과거에 저에게 도움이 되었기 때문입니다. 불행히도, 난 내 코드 실행의 시작 부분에 권리가 발생하는 원인 불명의 오류 메시지가 표시하고, 아래를 참조하십시오 :Fortran90 valgrind 출력 도움말. 코드 실행의 시작 부분에 설명되지 않은 오류가 발생했습니다.

==18257== Memcheck, a memory error detector 
==18257== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. 
==18257== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info 
==18257== Command: ./JFNKsolver 
==18257== 
==18257== Conditional jump or move depends on uninitialised value(s) 
==18257== at 0x6F7F7D: __intel_sse2_strcpy (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x6AA1C0: for__open_proc (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x67EF6C: for__open_default (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x69878D: for_write_seq_lis (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x65BA69: MAIN__ (JFNKsolver.f90:146) 
==18257== by 0x402DAD: main (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== Uninitialised value was created by a stack allocation 
==18257== at 0x6AA07D: for__open_proc (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== 
==18257== Conditional jump or move depends on uninitialised value(s) 
==18257== at 0x6F7F7D: __intel_sse2_strcpy (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x677DA5: for__add_to_lf_table (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x6ABA13: for__open_proc (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x67EF6C: for__open_default (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x69878D: for_write_seq_lis (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== by 0x65BA69: MAIN__ (JFNKsolver.f90:146) 
==18257== by 0x402DAD: main (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== Uninitialised value was created by a stack allocation 
==18257== at 0x6AA07D: for__open_proc (in /home/cseinen/Documents/1_Thesis_Work/ThesisGit/Model/Source_Code/JFNKsolver) 
==18257== 

나는 valgrind --track-origins=yes ./JFNKsolver 내 코드를 실행하여이 오류가 발생했습니다.

이제는 일반적으로 이러한 오류는 초기화되지 않은 변수가 어딘가에서 사용된다는 것을 의미하지만 이상한 점은 코드에서 실제로 일어나기 전에 나타 났으며 테스트 인쇄를 통해 by 0x65BA69: MAIN__ (JFNKsolver.f90:146)을 가리키고 있다는 것입니다. 성명서, 즉 아래 코드에 print *, "Test"입니다.

program JFNKsolver 

use modelparams    
use initialization   
use forcing     
use domain_routines   
use solver_routines   
use var_routines    
use csv_file     
use validation_routines  
use validsoln_routines  

implicit none 

real(kind = dbl_kind) :: & 
    time,  & 
    norm_test 

integer(kind = int_kind) :: & 
    nxT, nyT, & 
    nxN, nyN, & 
    nxU, nyU, & 
    nxV, nyV, & 
    nt,   & 
    nU_pnts, & 
    nV_pnts, & 
    nT_pnts, & 
    nN_pnts, & 
    nHT_pnts, & 
    nHN_pnts, & 
    si,   & 
    tmp_size, & 
    i, j, ij   


integer(kind = int_kind), allocatable, dimension (:) :: & 
    indxUi,  indxUj,   & 
    indxVi,  indxVj,   & 
    indxTi,  indxTj,   & 
    indxNi,  indxNj,   & 
    haloTi,  haloTj,   & 
    haloNi,  haloNj    

real(kind = dbl_kind), allocatable, dimension (:) :: & 
    Au,   res_NL,  u_update,  & 
    b,   b_0,  vpb_forc    

integer(kind = int_kind), allocatable, dimension (:,:,:) :: & 
    ulmsk,  vlmsk,  &    
    uimsk,  vimsk,  &    
    Timsk,  Nimsk,  &    
    Tlmsk,  Nlmsk      

real(kind = dbl_kind), allocatable, dimension (:,:) :: & 
    ugrid,  vgrid,        & 
    uResgrid, vResgrid,       & 
    uocn_u,  uocn_v,        & 
    vocn_u,  vocn_v,        & 
    uwnd_u,  uwnd_v,        & 
    vwnd_u,  vwnd_v,        & 
    h_u,  h_v,  h_T,     & 
          A_T,     & 
          P_T,  P_N,  & 
          zeta_T,  zeta_N,  & 
          eta_T,  eta_N,  & 
    Cw_u, Cw_v,         & 
          dist_T,  dist_N,  & 
          dist_gx_T,    & 
          dist_gy_T     

print *, "Test" 

주석 처리를 제거하고 종류 매개 변수를 modelparams 모듈에서 초기화했습니다. 누구나이 문제의 원인에 대해 통찰력을 줄 수 있습니까? use 문을 통해 사용중인 모듈에 연결할 수 있습니까? 원래 이것이 valgrind의 문제라고 생각했지만 지금은 메모리 손상의 영향을 보았습니다. 그리고 이것이 제가보고있는 유일한 오류라는 사실에주의를 기울였습니다.

참고 : 메모리 손상 문제가 있다고 생각하는 이유는 아무 것도 변경해서는 안되는 코드가있을 때만 내 솔버의 동작이 변경되기 때문입니다. 그것은 코드를 검증하는 데 도움을주기 위해 추가 한 기능이었고 이에 대한 광범위한 테스트를 수행했습니다.

답변

0

스티브 라이오넬은 Intel Developer Zone에서 본질적으로 같은 문제에 대답합니다.

Program Main 
    implicit none 
    write(*,*) "123" 
End Program 

컴파일 :

$ ifort -g main.f90 

이어서 불려 :

여기 사용 된 예시적인 프로그램이다

$ valgrind -v --track-origins=yes --leak-check=full ./a.out 

Valgrind의 위에서 본 본질적으로 동일한 출력을 리턴한다.

여기는 스티브의 답변입니다.

예. 올바른 것입니다. 암시 적으로 파일을 열었습니다. 할당 된 메모리가 필요합니다. 파일이 닫히지 않으므로 메모리는 프로그램 끝에서 할당 된 채로 남아 있습니다. 파일이 닫혀 있어도 (프로그램이 종료 될 때 암시 적으로 닫히는 경우에도 모든 부기 메모리가 할당 해제되지 않을 수 있습니다.) valgrind는 포트란을 인식하지 못합니다.

모두를 제거하지 못할 수도 있습니다. 내가 당신 경우 Valgrind의 불만.

그래서, 난 당신이있을 수 있습니다 이러한 경고를 무시하고 다른 사람을 보는 것입니다.

+0

감사합니다! 이러한 경고가 있다면 내가 인해 포트란과 valgrinds 부족에 궁금 해서요. ... 불행히도, 내가 얻는 다른 경고는 '== 6218 == 경고 : 주소 범위 설정 : 큰 범위 [0xa4d4040, 0x2532aa78] (정의되지 않음) == 6218 == 경고 : 주소 범위 설정 perms : 넓은 범위 [0xa4d4028, 0x2532aa90] (noaccess)' 내 연구에서, 이러한 것들이 valgrind 디버깅 목적으로 출력 된 경고라고 생각합니다. 버그를 구식 방식으로 찾아야 할 것처럼 보입니다. –

+0

@ClintSeinen 행운을 빌어 요. 문제를 예제로 좁히면 다른 질문을 게시하십시오. – muddle