[CP2K:7485] Buffer overflow in cp2k_shell.popt

Eric Hermes erich... at gmail.com
Wed Mar 9 12:11:53 UTC 2016


Dominik,

On Wednesday, March 9, 2016 at 2:55:05 AM UTC-6, Dominik Mierzejewski wrote:
>
> Hi, Eric. 
>
> On Tuesday, 08 March 2016 at 22:48, Eric Hermes wrote: 
> [...] 
> > This is why I am trying to build the cp2k_shell binaries in the first 
> > place. Unfortunately, I cannot get cp2k_shell to run at all, let alone 
> > within the framework of ASE. The problem is that the binary produces a 
> > buffer overflow when run by itself with no arguments. 
>
> Please try compiling with debugging information included (with gcc it's 
> enough to add -g to compiler flags, but I don't know the equivalent 
> for Intel compiler). Then, run the binary under gdb and post the output 
> of 'where' command once it crashes. 
>
> Regards, 
> Dominik 
> -- 
> Fedora http://fedoraproject.org/wiki/User:Rathann 
> RPMFusion http://rpmfusion.org 
> "Faith manages." 
>         -- Delenn to Lennier in Babylon 5:"Confessions and Lamentations" 
>
 
Slight correction to my previous post: the compiled executable does not 
result in a buffer overflow when it is run by itself, but only when it is 
run with mpirun. I have tried compiling CP2K with both mvapich2-2.2b and 
openmpi-1.10.2, and the buffer overflow happens for both of these MPI 
implementations. Since it only crashes when run with mpirun, and I do not 
know how to debug an MPI process with gdb (since it crashes immediately, I 
can't exactly attach gdb to the process once it's running), I don't think I 
can easily debug the process with gdb.

That said, I did try compiling CP2K with the Intel compiler debugging 
options enabled. What this showed was that any attempt to print or write to 
the screen was what was causing the buffer overflow. Specifically, it 
points to line 185 in cp2k_shell.f90, which after preprocessing looks like 
this:

  DO
     IF (para_env%mepos==para_env%source) THEN
        WRITE (sout,'("* READY")')
        CALL m_flush(sout)
     END IF

Line 185 is the one that contains the WRITE statement. I attempted 
debugging this issue by placing a simple 'print *, "Hello"' line above this 
on line 183, and after recompiling cp2k_shell.o and relinking 
cp2k_shell.popt, the resulting buffer overflow occurs at line 183 instead, 
with "Hello" not having been printed to the screen. I also tried explicitly 
writing to unit 6 with 'write (6, *) "Hello"', and this results in the same 
error.

Eric Hermes

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cp2k.org/archives/cp2k-user/attachments/20160309/3a6ede9f/attachment.htm>


More information about the CP2K-user mailing list