[R-pkg-devel] Stack smashing detected (dynamically loaded Fortran).

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Sun Feb 6 11:25:48 CET 2022


On Sun, 6 Feb 2022 12:45:15 +0300
Ivan Krylov <krylov.r00t using gmail.com> wrote:

> Unfortunately, demo.so keeps crashing R, seemingly because of memory
> corruption (e.g. the function name turns out to be overwritten when
> producing the error message 'array overflow in .Fortran("%s")')

I installed debugging symbols for R, set a watchpoint on the local
symName in function do_dotCode, one call frame above subroutine getgl,
and it hit:

Thread 1 "R" hit Watchpoint 3: symName

0x00007ffff24bb6a3 in derivf (fy=..., ndistr=4, zeta=..., sigma=...,
size=1, y=1, ymiss=0, dmat=..., kstate=2, npar=10, nphi=8, nyv=5,
nxc=1, d1f=..., d2f=..., d1zeta=..., d2zeta=..., d1u=..., d2u=...,
nd=1, epars=..., den=...) at derivf.f:59
 59            d2f(j,k,l) = epars(iy,j)*(a-b+c)/den(j)**2

d2f is declared to have dimensions (kstate,npar,npar) in derivf.f, but
is only a real(kind=8) in its caller, getgl.f. Setting the correct
dimensions in getgl.f seems to fix the crash.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list