Hello, I've compiled some Fortran code and dyn.loaded it into R as in the "Writing R Extensions" manual. The code receives four large arrays of doubles from R (size about 3000x3000), and runs through several loops with BLAS calls. However, I get a memory corruption error when running it -- the full output is attached at the end. I've been trying to pinpoint and solve the problem, and two things seem odd to me: First, if I run the same code with a much smaller data set, so that the arrays are about 500x500 each, there are no problems (this seems to indicate that I'm not writing outside array bounds). Second, using the gdb debugger (with ddd frontend), I noticed that the error only occurs on the second pass through the main Fortran code loop, which should not be very different from the first. The crash occurs during a call to the BLAS routine DSYR. I've been trying to replicate the problem in a smaller code snippet for posting to the list, but haven't had any luck so far. Perhaps there are some ideas based on the output? This is with R 2.4.1 on Ubuntu, and also occurs with R 2.4.1 on Mac OS X (gcc 3.4.6 and 3.4.2 respectively). Many thanks, Emmanuel *** glibc detected *** /usr/lib/R/bin/exec/R: malloc(): memory corruption: 0xb7c42480 *** ======= Backtrace: ========/lib/tls/i686/cmov/libc.so.6[0xb7b781cd] /lib/tls/i686/cmov/libc.so.6(malloc+0x7f)[0xb7b7983f] /usr/lib/atlas/sse2/libblas.so.3(ATL_dsyr+0x7f)[0xb77ec16f] ======= Memory map: =======08048000-08049000 r-xp 00000000 08:03 967805 /usr/lib/R/bin/exec/R 08049000-0804a000 rw-p 00000000 08:03 967805 /usr/lib/R/bin/exec/R 0804a000-08d74000 rw-p 0804a000 00:00 0 [heap] 93600000-93621000 rw-p 93600000 00:00 0 93621000-93700000 ---p 93621000 00:00 0 937bb000-b6f74000 rw-p 937bb000 00:00 0 b6f74000-b70aa000 r-xp 00000000 08:03 967808 /usr/lib/R/lib/ libRlapack.so b70aa000-b70ab000 rw-p 00136000 08:03 967808 /usr/lib/R/lib/ libRlapack.so b70ab000-b716e000 rw-p b70ab000 00:00 0 b716e000-b71cd000 r-xp 00000000 08:03 983801 /usr/lib/R/library/ stats/libs/stats.so b71cd000-b71cf000 rw-p 0005e000 08:03 983801 /usr/lib/R/library/ stats/libs/stats.so b71cf000-b723d000 rw-p b71cf000 00:00 0 b723d000-b725b000 r-xp 00000000 08:03 983477 /usr/lib/R/library/ grDevices/libs/grDevices.so b725b000-b725c000 rw-p 0001e000 08:03 983477 /usr/lib/R/library/ grDevices/libs/grDevices.so b725c000-b7265000 r-xp 00000000 08:03 967490 /lib/tls/i686/cmov/ libnss_files-2.4.so b7265000-b7267000 rw-p 00008000 08:03 967490 /lib/tls/i686/cmov/ libnss_files-2.4.so b7267000-b726f000 r-xp 00000000 08:03 967494 /lib/tls/i686/cmov/ libnss_nis-2.4.so b726f000-b7271000 rw-p 00007000 08:03 967494 /lib/tls/i686/cmov/ libnss_nis-2.4.so b7271000-b7283000 r-xp 00000000 08:03 967484 /lib/tls/i686/cmov/ libnsl-2.4.so b7283000-b7285000 rw-p 00011000 08:03 967484 /lib/tls/i686/cmov/ libnsl-2.4.so b7285000-b7287000 rw-p b7285000 00:00 0 b7287000-b728e000 r-xp 00000000 08:03 967486 /lib/tls/i686/cmov/ libnss_compat-2.4.so b728e000-b7290000 rw-p 00006000 08:03 967486 /lib/tls/i686/cmov/ libnss_compat-2.4.so b7293000-b7296000 r-xp 00000000 00:15 265 /media/mac/rd2.so b7296000-b7297000 rw-p 00002000 00:15 265 /media/mac/rd2.so b7297000-b729d000 r-xp 00000000 08:03 984591 /usr/lib/R/library/ methods/libs/methods.so b729d000-b729e000 rw-p 00005000 08:03 984591 /usr/lib/R/library/ methods/libs/methods.so b729e000-b729f000 r-xp 00000000 08:03 901812 /usr/lib/gconv/ ISO8859-1.so b729f000-b72a1000 rw-p 00001000 08:03 901812 /usr/lib/gconv/ ISO8859-1.so b72a1000-b72e2000 rw-p b72a1000 00:00 0 b72e2000-b72e3000 r--p 00000000 08:03 985193 /usr/share/R/share/ locale/en/LC_MESSAGES/R.mo b72e3000-b7316000 rw-p b72e3000 00:00 0 b7316000-b73ed000 r--p 00000000 08:03 969067 /usr/lib/locale/ en_US.utf8/LC_COLLATE b73ed000-b7420000 r--p 00000000 08:03 969068 /usr/lib/locale/ en_US.utf8/LC_CTYPE b7420000-b7422000 rw-p b7420000 00:00 0 b7422000-b7459000 r-xp 00000000 08:03 933965 /lib/libncurses.so.5.5 b7459000-b7461000 rw-p 00037000 08:03 933965 /lib/libncurses.so.5.5 b7461000-b7462000 rw-p b7461000 00:00 0 b7462000-b7464000 r-xp 00000000 08:03 967479 /lib/tls/i686/cmov/ libdl-2.4.so b7464000-b7466000 rw-p 00001000 08:03 967479 /lib/tls/i686/cmov/ libdl-2.4.so b7466000-b7479000 r-xp 00000000 08:03 870346 /usr/lib/libz.so.1.2.3 b7479000-b747a000 rw-p 00012000 08:03 870346 /usr/lib/libz.so.1.2.3 b747a000-b7489000 r-xp 00000000 08:03 933929 /lib/libbz2.so.1.0.3 b7489000-b748a000 rw-p 0000f000 08:03 933929 /lib/libbz2.so.1.0.3 b748a000-b748b000 rw-p b748a000 00:00 0 b748b000-b74a2000 r-xp 00000000 08:03 870020 /usr/lib/libpcre.so. 3.12.0 b74a2000-b74b9000 rw-p 00016000 08:03 870020 /usr/lib/libpcre.so. 3.12.0 b74b9000-b74e2000 r-xp 00000000 08:03 933997 /lib/libreadline.so.5.1 b74e2000-b74e6000 rw-p 00029000 08:03 933997 /lib/libreadline.so.5.1 b74e6000-b74e7000 rw-p b74e6000 00:00 0 b74e7000-b74f1000 r-xp 00000000 08:03 933955 /lib/libgcc_s.so.1 b74f1000-b74f2000 rw-p 00009000 08:03 933955 /lib/libgcc_s.so.1 b74f2000-b7516000 r-xp 00000000 08:03 967481 /lib/tls/i686/cmov/ libm-2.4.so b7516000-b7518000 rw-p 00023000 08:03 967481 /lib/tls/i686/cmov/ libm-2.4.so b7518000-b7531000 r-xp 00000000 08:03 869976 /usr/lib/libg2c.so. 0.0.0 b7531000-b7532000 rw-p 00019000 08:03 869976 /usr/lib/libg2c.so. 0.0.0 b7532000-b753f000 rw-p b7532000 00:00 0 b753f000-b7b0b000 r-xp 00000000 08:03 1478971 /usr/lib/atlas/sse2/ libblas.so.3.0 b7b0b000-b7b10000 rw-p 005cc000 08:03 1478971 /usr/lib/atlas/sse2/ libblas.so.3.0 b7b10000-b7b11000 rw-p b7b10000 00:00 0 b7b11000-b7c3e000 r-xp 00000000 08:03 967473 /lib/tls/i686/cmov/ libc-2.4.so b7c3e000-b7c40000 r--p 0012c000 08:03 967473 /lib/tls/i686/cmov/ libc-2.4.so b7c40000-b7c42000 rw-p 0012e000 08:03 967473 /lib/tls/i686/cmov/ libc-2.4.so b7c42000-b7c45000 rw-p b7c42000 00:00 0 b7c47000-b7c48000 r--p 00000000 08:03 969070 /usr/lib/locale/ en_US.utf8/LC_MEASUREMENT b7c48000-b7c49000 r--p 00000000 08:03 969074 /usr/lib/locale/ en_US.utf8/LC_PAPER b7c49000-b7c4a000 r--p 00000000 08:03 969071 /usr/lib/locale/ en_US.utf8/LC_MONETARY b7c4a000-b7c4b000 r--p 00000000 08:03 969076 /usr/lib/locale/ en_US.utf8/LC_TIME b7c4b000-b7c52000 r--s 00000000 08:03 901864 /usr/lib/gconv/gconv- modules.cache b7c52000-b7c53000 r--p 00000000 08:03 999466 /usr/lib/locale/ en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES b7c53000-b7e7e000 r-xp 00000000 08:03 967807 /usr/lib/R/lib/libR.so b7e7e000-b7e8b000 rw-p 0022a000 08:03 967807 /usr/lib/R/lib/libR.so b7e8b000-b7f24000 rw-p b7e8b000 00:00 0 b7f24000-b7f3d000 r-xp 00000000 08:03 933910 /lib/ld-2.4.so b7f3d000-b7f3f000 rw-p 00018000 08:03 933910 /lib/ld-2.4.so bfae6000-bfb71000 rwxp bfae6000 00:00 0 [stack] bfb71000-bfb74000 rw-p bfb71000 00:00 0 ffffe000-fffff000 ---p 00000000 00:00 0 [vdso] Aborted (core dumped)