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

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Sun Feb 6 04:32:05 CET 2022


In the past when I've got the "stack smashing detected" error, it turned
out to be due to that fact that I'd omitted an argument in a call to a
Fortran subroutine, or had in some similar way buggered up an argument
list.

In this instance, I've been tearing my hair out all day and can find no
discrepancies between argument lists in calls and in the code of
subroutines called.

The output that I get from valgrind (see the attached file "smash.txt")
does not enlighten me.  Perhaps someone cleverer than I can extract
useful information from it.  Or perhaps someone can suggest some other
means of discerning what is going wrong.

Should anyone have the inclination and patience to delve further, I have
made a tarball of (a somewhat stripped down version of) the problematic
code and put it up on my web page.  To get to it, go to

    https://www.stat.auckland.ac.nz/~rolf/

scroll down to the bottom and click on "Smash".

If you feel motivated to do so, download the tarball, extract the
contents ("tar xvf smash.tar.gz"), execute "R -d valgrind" in the
directory into which you downloaded smash.tar.gz, and then execute
source("demo.R").

If you amend the Fortran code you will of course need to rebuild the
shared library object:  R CMD SHLIB -o demo.so *.f

The Fortran code is pretty opaque since I actually wrote the code in
ratfor and then compiled it into Fortran.  If you have ratfor on your
system you could amend the *.r files (included in the tarball) and then
execute "makefor" (also in the tarball) to build the Fortran code.
    
I'd be grateful for any insight that anyone can provide.

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: smash.txt
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20220206/13526cac/attachment.txt>


More information about the R-package-devel mailing list