Gaspard Lequeux
2010-Sep-29 15:39 UTC
[R] R crashes when loading rgl package before minqa package
Hej, Calling newuoa (from the minqa package) makes R crash when the package rgl is loaded first. This however only on certain selected data. The data used for testing (saved to 'bugs.R'): xvals = c(1,2,4,5,7,8,9,10,11,12,14,15,16,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36) yvals = c(857.7597,975.8624,978.2655,979.3034,965.5919,983.8946,992.2512,992.1178,979.5379,974.4269,968.4113,991.5210,977.3361,985.7800,975.5220,974.6880,973.8102,980.7295,982.0034,984.7993,978.4948,970.4351,969.0718,983.7892,976.3637,980.7833,987.1665,976.6000,975.1332,971.0757,989.4693) initpar = c(-5.1471384, -3861.8905839, 979.2616002, 0.2572355, 27.5705764) optimft <- function(x) { yft = x[2] + (x[3] - x[2])/((1 + exp(x[1] * (log(xvals) - log(x[4]))))^x[5]) return(sum((yvals - yft)^2)) } Sequence of commands needed to make the bug appear: <Start R> source('bugs.R') library(minqa) library(rgl) newuoa(initpar, optimft) => OK <Start R> source('bugs.R') library(rgl) library(minqa) newuoa(initpar, optimft) => Crash: segfault: address 0x18, cause 'memory not mapped' I found the bug using the package qpcR, where rgl is loaded when loading qpcR while minqa is only loaded later, when needed. Running on Debian squeeze 64 bit. R version: R version 2.11.1 (2010-05-31) x86_64-pc-linux-gnu rgl version: 0.91 minqa version: 1.1.9 Rcpp version: 0.8.6 (loaded by minqa) Kind regards, Gaspard Lequeux
Ben Bolker
2010-Sep-30 13:54 UTC
[R] R crashes when loading rgl package before minqa package
Gaspard Lequeux <Gaspard.Lequeux <at> biomath.ugent.be> writes:> Calling newuoa (from the minqa package) makes R crash when > the package rgl > is loaded first. This however only on certain selected data. > > The data used for testing (saved to 'bugs.R'): > > xvals c(1,2,4,5,7,8,9,10,11,12,14,15,16,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36)> > yvals c(857.7597,975.8624,978.2655,979.3034,965.5919,983.8946,992.2512,992.1178,979.5379,974.4269,968.4113,991.5210,977.3361,985.7800, 975.5220,974.6880,973.8102,980.7295,982.0034,984.7993,978.4948, 970.4351,969.0718,983.7892,976.3637,980.7833,987.1665,976.6000, 975.1332,971.0757,989.4693)> > initpar = c(-5.1471384, -3861.8905839, 979.2616002, 0.2572355, 27.5705764) > > optimft <- function(x) { > yft = x[2] + (x[3] - x[2])/((1 + exp(x[1] * (log(xvals) - log(x[4]))))^x[5]) > return(sum((yvals - yft)^2)) > } > > Sequence of commands needed to make the bug appear: > > <Start R> > source('bugs.R') > library(minqa) > library(rgl) > newuoa(initpar, optimft) > => OK > > <Start R> > source('bugs.R') > library(rgl) > library(minqa) > newuoa(initpar, optimft) > => Crash: segfault: address 0x18, cause 'memory not mapped' > > I found the bug using the package qpcR, where rgl is loaded when loading > qpcR while minqa is only loaded later, when needed. > > Running on Debian squeeze 64 bit. > R version: R version 2.11.1 (2010-05-31) x86_64-pc-linux-gnu > rgl version: 0.91 > minqa version: 1.1.9 > Rcpp version: 0.8.6 (loaded by minqa) > > Kind regards, > > Gaspard LequeuxDuplicated on Ubuntu 10.04> sessionInfo()R version 2.11.1 (2010-05-31) i486-pc-linux-gnu locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] minqa_1.1.9 Rcpp_0.8.6 rgl_0.91.787 Running valgrind: bolker at ubuntu-10:~/R/misc$ R -d valgrind --vanilla ==26985== Memcheck, a memory error detector ==26985== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==26985== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info ==26985== Command: /usr/lib/R/bin/exec/R --vanilla ==26985== R version 2.11.1 (2010-05-31) [snip startup info]> xvals c(1,2,4,5,7,8,9,10,11,12,14,15,16,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36)> > yvals c(857.7597,975.8624,978.2655,979.3034,965.5919,983.8946,992.2512,992.1178,979.5379,974.4269,968.4113, 991.5210,977.3361,985.7800,975.5220,974.6880,973.8102, 980.7295,982.0034,984.7993,978.4948,970.4351,969.0718, 983.7892,976.3637,980.7833,987.1665,976.6000,975.1332, 971.0757,989.4693)> > initpar = c(-5.1471384, -3861.8905839, 979.2616002, 0.2572355, 27.5705764) > > optimft <- function(x) {+ yft = x[2] + (x[3] - x[2])/((1 + exp(x[1] * (log(xvals) - log(x[4]))))^x[5]) + return(sum((yvals - yft)^2)) + }> > library(rgl) > library(minqa)Loading required package: Rcpp> newuoa(initpar, optimft)==26985== Invalid read of size 4 ==26985== at 0x6763C17: __cxa_allocate_exception (in /usr/lib/libstdc++.so.6.0.13) ==26985== by 0x6EC026E: calfun_ (minqa.cpp:30) ==26985== by 0x6EC4F56: newuob_ (newuob.f:323) ==26985== by 0x6EC4ADA: newuoa_ (newuoa.f:68) ==26985== by 0x6EC2350: newuoa_cpp__rcpp__wrapper__(Rcpp::Vector<14>, Rcpp::Environment, SEXPREC*) (minqa.cpp:120) ==26985== by 0x6EC27D1: newuoa_cpp (minqa.cpp:110) ==26985== by 0x40BB170: ??? (in /usr/lib/R/lib/libR.so) ==26985== by 0x40F20C1: Rf_eval (in /usr/lib/R/lib/libR.so) ==26985== by 0x40F42BF: ??? (in /usr/lib/R/lib/libR.so) ==26985== by 0x40F1E37: Rf_eval (in /usr/lib/R/lib/libR.so) ==26985== by 0x40F5C6F: Rf_applyClosure (in /usr/lib/R/lib/libR.so) ==26985== by 0x40F1CDC: Rf_eval (in /usr/lib/R/lib/libR.so) ==26985== Address 0xc is not stack'd, malloc'd or (recently) free'd ==26985== *** caught segfault *** address 0xc, cause 'memory not mapped' Traceback: 1: .Call(newuoa_cpp, par, ctrl, fn1) 2: newuoa(initpar, optimft) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: I strongly suspect that the problem is with minqa, and that loading rgl is just a way to make the problem surface. I may take a look at minqa , but you may want to send an e-mail to the maintainer [ maintainer("minqa") ] as well ... Ben Bolker
Ravi Varadhan
2010-Sep-30 14:14 UTC
[R] R crashes when loading rgl package before minqa package
I get this on Windows (it does not crash):> library(minqa) > library(rgl) > newuoa(initpar, optimft)Error in newuoa(initpar, optimft) : non-finite x values not allowed in calfun In addition: Warning message: In log(x[4]) : NaNs produced>This tells me that you should be constraining your parameter x[4] (may be even x[5]) to be non-negative: Here is what I get with `bobyqa':> bobyqa(initpar, optimft, lower=c(-Inf, -Inf, -Inf, 0, 0))parameter estimates: -5.311767080681, -3861.89005072333, 979.239647766226, 0.268156271922112, 27.6418856936228 objective: 1457.20987728737 number of function evaluations: 78>Ravi. ____________________________________________________________________ Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu ----- Original Message ----- From: Gaspard Lequeux <Gaspard.Lequeux at biomath.ugent.be> Date: Wednesday, September 29, 2010 11:40 am Subject: [R] R crashes when loading rgl package before minqa package To: r-help at r-project.org> Hej, > > Calling newuoa (from the minqa package) makes R crash when the > package rgl is loaded first. This however only on certain selected data. > > The data used for testing (saved to 'bugs.R'): > > > xvals = c(1,2,4,5,7,8,9,10,11,12,14,15,16,18,19,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36) > > yvals = c(857.7597,975.8624,978.2655,979.3034,965.5919,983.8946,992.2512,992.1178,979.5379,974.4269,968.4113,991.5210,977.3361,985.7800,975.5220,974.6880,973.8102,980.7295,982.0034,984.7993,978.4948,970.4351,969.0718,983.7892,976.3637,980.7833,987.1665,976.6000,975.1332,971.0757,989.4693) > > initpar = c(-5.1471384, -3861.8905839, 979.2616002, 0.2572355, 27.5705764) > > optimft <- function(x) { > yft = x[2] + (x[3] - x[2])/((1 + exp(x[1] * (log(xvals) - log(x[4]))))^x[5]) > return(sum((yvals - yft)^2)) > } > > > Sequence of commands needed to make the bug appear: > > <Start R> > source('bugs.R') > library(minqa) > library(rgl) > newuoa(initpar, optimft) > => OK > > <Start R> > source('bugs.R') > library(rgl) > library(minqa) > newuoa(initpar, optimft) > => Crash: segfault: address 0x18, cause 'memory not mapped' > > I found the bug using the package qpcR, where rgl is loaded when > loading qpcR while minqa is only loaded later, when needed. > > > Running on Debian squeeze 64 bit. > R version: R version 2.11.1 (2010-05-31) x86_64-pc-linux-gnu > rgl version: 0.91 > minqa version: 1.1.9 > Rcpp version: 0.8.6 (loaded by minqa) > > Kind regards, > > Gaspard Lequeux > > ______________________________________________ > R-help at r-project.org mailing list > > PLEASE do read the posting guide > and provide commented, minimal, self-contained, reproducible code.