Bug 15244 - Rgui.exe crashing randomly when using stats::nlminb
Summary: Rgui.exe crashing randomly when using stats::nlminb
Status: CLOSED DUPLICATE of bug 15914
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 3.0.0
Hardware: ix86 (32-bit) All
: P3 major
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2013-03-24 20:04 UTC by wurzer.juergen
Modified: 2015-12-14 13:46 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wurzer.juergen 2013-03-24 20:04:00 UTC
Since weeks I face issues with randomly crashing Rgui.exe instances. I could narrow it down to the nlminb() function. I am using that function quite often.

Reproducing the error unfortunately needs some time due to the reason that the cash seems to occur randomly.

Here is a sample code. It is just executing some nlminb() samples (as provided in the documentation) within two loops:

nIter1 <- 1000
nIter2 <- 1000

for (numI in seq_len(nIter1)) {
	x <- rnbinom(100, mu = 10, size = 10)
	hdev <- function(par)
		-sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
	for (numJ in seq_len(nIter2)) {
		foo <- nlminb(c(9, 12), hdev)
		foo <- nlminb(c(20, 20), hdev, lower = 0, upper = Inf)
		foo <- nlminb(c(20, 20), hdev, lower = 0.001, upper = Inf)
	}
	cat(numI,"\n")
	Sys.sleep(1)
}


Usually Rgui.exe crashes within the first few iterations, sometimes it needs around 100-300 iterations and I also had some rare cases where all 1000 iterations (nIter1) were successful. But, right after re-starting R and running the code again it crashed. It really drives me mad because it occurs randomly.
In my scripts it crashes a bit more reliably (although also randomly), but due to the amount of data involved I thought the shorter example is more useful for you.

I successfully cashed Rgui.exe on three different machines using the code above:
- Windows XP - Intel Core i5 - 4GB RAM - R 2.15.1
- Windows 7 - Intel Core i5 - 8GB RAM - R 2.15.1
- Windows 8 - Intel Core i5 - 8GB RAM - R 2.15.2 and latest R 2.15.3

It also crashed vanilla sessions of R. Here is the sessionInfo() output (same on all machines, just different R Version, but localization and attached packages are identical):
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Austria.1252  LC_CTYPE=German_Austria.1252    LC_MONETARY=German_Austria.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Austria.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base 


Windows 8 shows the following crash information (sorry, German):
Problemsignatur:
  Problemereignisname:	APPCRASH
  Anwendungsname:	Rgui.exe
  Anwendungsversion:	2.153.62090.0
  Anwendungszeitstempel:	51308af8
  Fehlermodulname:	stats.dll
  Fehlermodulversion:	2.153.62090.0
  Fehlermodulzeitstempel:	51308b85
  Ausnahmecode:	c0000005
  Ausnahmeoffset:	000239f5
  Betriebsystemversion:	6.2.9200.2.0.0.256.103
  Gebietsschema-ID:	3079
  Zusatzinformation 1:	5861
  Zusatzinformation 2:	5861822e1919d7c014bbb064c64908b2
  Zusatzinformation 3:	f3d5
  Zusatzinformation 4:	f3d5be0cad2787556264647dc02181c3

If there is any information I can provide in addition I am pleased to help, but unfortunately I have no clue how to solve / workaround this issue. Also searching the Internet did not really help.

Thanks for taking a look at it.
Comment 1 wurzer.juergen 2013-04-07 10:55:12 UTC
I installed R 3.0.0 today, many thanks for this great release. Unfortunately the nlminb() error persists.

When running my example below Rgui.exe crashes randomly with Windows 8 showing the following error messsage:

Problemsignatur:
  Problemereignisname:	APPCRASH
  Anwendungsname:	Rgui.exe
  Anwendungsversion:	3.0.62481.0
  Anwendungszeitstempel:	515c1d20
  Fehlermodulname:	stats.dll
  Fehlermodulversion:	3.0.62481.0
  Fehlermodulzeitstempel:	515c1ddf
  Ausnahmecode:	c0000005
  Ausnahmeoffset:	000245c5
  Betriebsystemversion:	6.2.9200.2.0.0.256.103
  Gebietsschema-ID:	3079
  Zusatzinformation 1:	5861
  Zusatzinformation 2:	5861822e1919d7c014bbb064c64908b2
  Zusatzinformation 3:	f3d5
  Zusatzinformation 4:	f3d5be0cad2787556264647dc02181c3
Comment 2 Peter Dalgaard 2013-04-07 17:20:13 UTC
It could be useful to know whether this is strictly an RGui issue, or Windows R, or generic R. I haven't been able to reproduce the effect with OSX. 

Will the code generate the same fault if run under Rterm?
Comment 3 wurzer.juergen 2013-04-07 22:27:19 UTC
Peter, many thanks for your reply. I can confirm that the code also crashes Rterm.exe. Here is the Windows 8 error message:

Problemsignatur:
  Problemereignisname:	APPCRASH
  Anwendungsname:	Rterm.exe
  Anwendungsversion:	3.0.62481.0
  Anwendungszeitstempel:	515c1d20
  Fehlermodulname:	stats.dll
  Fehlermodulversion:	3.0.62481.0
  Fehlermodulzeitstempel:	515c1ddf
  Ausnahmecode:	c0000005
  Ausnahmeoffset:	000245c5
  Betriebsystemversion:	6.2.9200.2.0.0.256.103
  Gebietsschema-ID:	3079
  Zusatzinformation 1:	5861
  Zusatzinformation 2:	5861822e1919d7c014bbb064c64908b2
  Zusatzinformation 3:	f3d5
  Zusatzinformation 4:	f3d5be0cad2787556264647dc02181c3

I tested the sample code on the following machines (always running R i386):
- Windows XP - Intel Core i5 - 4GB RAM - R 2.15.1
- Windows 7 - Intel Core i5 - 8GB RAM - R 2.15.1
- Windows 8 - Intel Core i5 - 8GB RAM - R 2.15.2, R 2.15.3, R 3.0.0

Sometimes (quite seldom) the code is executed without any problems, usually it crashes around the 100st-300st iteration. Maybe you need to run the script several times in different R instances.
As mentioned I originally faced the error in a different script involving more data. That script is crashing more reliable. If you want I can send you the involved data and the script via E-Mail, since sharing it publicly is not possible.

Maybe another detail: I am usually storing the code in a file and sourcing that file. This should make no major difference, but as far as I am aware the source() command is interpreting the code slightly different than just entering the code in the console. Nonetheless as far as I remember I was also able to crash R when just entering the code into the console (would have to verify that again).

I am pleased to provide everything that helps!

Here is the Rterm.exe sessionInfo() Output:

R version 3.0.0 (2013-04-03)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Austria.1252  LC_CTYPE=German_Austria.1252   
[3] LC_MONETARY=German_Austria.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Austria.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Comment 4 Hannes Mühleisen 2013-07-31 14:42:06 UTC
This issue might not be related to nlminb. I have a very similar problem, where a process only crashes after running without issues for a number of times. Similarly, this only occurs on Windows. Unfortunately, it is difficult to create a test case for my instance, since it involves DB operations.
Comment 5 Brian Ripley 2013-12-11 16:42:30 UTC
We cannot reproduce this, and we cannot debug on your machine.  If you run a debug-enabled build of R under a debugger (gdb or Dr. Memory?) you will be able to get useful information.
Comment 6 Duncan Murdoch 2014-07-30 16:27:17 UTC

*** This bug has been marked as a duplicate of bug 15914 ***