http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55341



--- Comment #40 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
2012-12-21 08:03:49 UTC ---

After getting an asan instrumented libgfortran to work (thanks hjl, jakub), I'm

still getting the error message.



==66645== ERROR: AddressSanitizer: stack-buffer-overflow on address

0x7fff28abdbf0 at pc 0x4472da bp 0x7fff28abdbc0 sp 0x7fff28abdbb8

WRITE of size 4 at 0x7fff28abdbf0 thread T0

    #0 0x4472d9 in __cp_log_handling_MOD_cp_int_to_string

/data/vjoost/gnu/cp2k/cp2k/src/../src/cp_log_handling.F:882

    #1 0x6419b5 in __input_section_types_MOD_section_vals_get_subs_vals

/data/vjoost/gnu/cp2k/cp2k/src/../src/input_section_types.F:1103 (discriminator

2)

    #2 0x48a77b in __f77_interface_MOD_create_force_env

/data/vjoost/gnu/cp2k/cp2k/src/../src/f77_interface.F:817

    #3 0x41566a in __cp2k_runs_MOD_cp2k_run

/data/vjoost/gnu/cp2k/cp2k/src/../src/cp2k_runs.F:307

    #4 0x4167f2 in __cp2k_runs_MOD_run_input

/data/vjoost/gnu/cp2k/cp2k/src/../src/cp2k_runs.F:1133

    #5 0x407289 in cp2k /data/vjoost/gnu/cp2k/cp2k/src/../src/cp2k.F:285

    #6 0x40751a in main /data/vjoost/gnu/cp2k/cp2k/src/../src/cp2k.F:41

    #7 0x351661ecdc in ?? ??:0

==66645== AddressSanitizer CHECK failed:

../../../../gcc/libsanitizer/asan/asan_report.cc:149 "((name_end)) != (0)"

(0x0, 0x0)

    #0 0x7fadc8913d83 in AsanCheckFailed _asan_rtl_



The subroutine is sufficiently simple to be 'sure' there is nothing wrong

there:



  FUNCTION cp_int_to_string(i) RESULT(res)

    INTEGER, INTENT(in)                      :: i

    CHARACTER(len=6)                         :: res



    INTEGER                                  :: iostat

    REAL(KIND=dp)                            :: tmp_r



    IF (i>999999 .OR. i<-99999) THEN

       tmp_r=i

       WRITE (res,fmt='(es6.1)',iostat=iostat) tmp_r

    ELSE

       WRITE (res,fmt='(i6)',iostat=iostat) i   ! line 882

    END IF

    IF (iostat/=0) THEN

       PRINT *,"cp_int_to_string ioerror",iostat

       CALL print_stack(cp_logger_get_default_unit_nr())

    END IF

  END FUNCTION cp_int_to_string



so I'm still thinking the cause is elsewhere (also because -O0 and -O1 show

differences in behavior). I'm attaching the objdump of the module, in case this

is useful. I can also provide build instructions for our package and how to

reproduce the bug, but it is not a small reproducer, unfortunately.

Reply via email to