secr.test with certain models crashes R

56 views
Skip to first unread message

Scott Appleby

unread,
Nov 2, 2022, 11:47:38 AM11/2/22
to secr
Hi Again!

I may have found a crash bug in secr.test (or perhaps in sim.secr called by secr.test); I am not sure exactly what the problem is (maybe a memory issue) but the trigger seems to be related to my model parameters.  Perhaps the “fix” is just another check and fail to error message to prevent the R crash, but I’m not really sure.

I’ve included the code to trigger the crash, along with an RDS file of my secr.fit outputs for 4 different models using the same multi-session capture data.  The first one runs fine with secr.test (albeit very slowly), I stopped it after the first “sim.secr fitting replicate 1…” message but I assume it would continue.  The fourth one triggers a crash in less than a minute before anything prints to the console.  The second and third secr.fit outputs I didn’t try running with secr.test, but are included in case the variations are helpful.

Thanks,

Scott

### secr.test crash example ###

library(secr)
library(dplyr)

SECR_S4_M4G1_SMAM_C245 <- readRDS("SECR_S4_M4G1_SMAM_C245.RDS")

### This one runs ###
secr.test_Test1 <- SECR_S4_M4G1_SMAM_C245 %>%
  filter(rn==1) %>%
  pull(results) %>%
  .[[1]] %>%
  secr.test(.,fit=TRUE)

### This one crashes R ###
secr.test_Test2 <- SECR_S4_M4G1_SMAM_C245 %>%
  filter(rn==4) %>%
  pull(results) %>%
  .[[1]] %>%
  secr.test(.,fit=TRUE)


SECR_S4_M4G1_SMAM_C245.RDS

Scott Appleby

unread,
Nov 2, 2022, 11:48:22 AM11/2/22
to secr

Additionally, in case it helps, here is what I think is the relevant part of the R crash log (long):
---------------------------------------------------------------------------

Process: rsession [25860]
Path: /Applications/RStudio.app/Contents/MacOS/rsession
Identifier: rsession
Version: 0
Code Type: X86-64 (Native)
Parent Process: RStudio [25724]
Responsible: RStudio [25724]
User ID: 501


Date/Time: 2022-11-02 15:47:29.913 +0100
OS Version: Mac OS X 10.15.7 (19H2026)
Report Version: 12
Anonymous UUID: 317D22ED-291E-D3F3-2F22-D3DF7D5D0774


Sleep/Wake UUID: D86A05DF-538D-4DFE-91C5-FF20EFB49B0B


Time Awake Since Boot: 150000 seconds
Time Since Wake: 25000 seconds


System Integrity Protection: enabled


Crashed Thread: 0 Dispatch queue: com.apple.main-thread


Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00007fe9fd08c150
Exception Note: EXC_CORPSE_NOTIFY


VM Regions Near 0x7fe9fd08c150:
MALLOC_LARGE 00007fe9fcfac000-00007fe9fd08c000 [ 896K] rw-/rwx SM=PRV  
--> 
MALLOC_LARGE 00007fe9fd0dd000-00007fe9fd0fc000 [ 124K] rw-/rwx SM=PRV  


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 secr.so 0x000000010a0deaf2 simdetectpointcpp(int, int, int, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<13, Rcpp::PreserveStorage> const&, Rcpp::Vector<13, Rcpp::PreserveStorage> const&, int, Rcpp::Vector<13, Rcpp::PreserveStorage> const&, Rcpp::Vector<14, Rcpp::PreserveStorage> const&, Rcpp::Matrix<14, Rcpp::PreserveStorage> const&, int, int, Rcpp::Vector<13, Rcpp::PreserveStorage> const&) + 2722
1 secr.so 0x000000010a07eea6 _secr_simdetectpointcpp + 646 (RcppExports.cpp:550)
2 libR.dylib 0x000000010266db3c R_doDotCall + 1676
3 libR.dylib 0x000000010266f3ee do_dotcall + 334 (dotcode.c:1284)
4 libR.dylib 0x00000001026a71b5 bcEval + 28565 (eval.c:7136)
5 libR.dylib 0x000000010269fb81 Rf_eval + 385
6 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
7 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
8 libR.dylib 0x00000001026a6aae bcEval + 26766 (eval.c:7104)
9 libR.dylib 0x000000010269fb81 Rf_eval + 385
10 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
11 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
12 libR.dylib 0x00000001026a6aae bcEval + 26766 (eval.c:7104)
13 libR.dylib 0x000000010269fb81 Rf_eval + 385
14 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
15 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
16 libR.dylib 0x00000001026c0674 R_forceAndCall + 868 (eval.c:1985)
17 libR.dylib 0x00000001025fd886 do_lapply + 1094 (apply.c:76)
18 libR.dylib 0x0000000102709d8a do_internal + 362 (names.c:1399)
19 libR.dylib 0x00000001026a738d bcEval + 29037 (eval.c:7156)
20 libR.dylib 0x000000010269fb81 Rf_eval + 385
21 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
22 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
23 libR.dylib 0x00000001026a6aae bcEval + 26766 (eval.c:7104)
24 libR.dylib 0x000000010269fb81 Rf_eval + 385
25 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
26 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
27 libR.dylib 0x000000010270bfe7 dispatchMethod + 775 (objects.c:437)
28 libR.dylib 0x000000010270bcaf Rf_usemethod + 735 (objects.c:476)
29 libR.dylib 0x000000010270c307 do_usemethod + 743 (objects.c:565)
30 libR.dylib 0x00000001026a738d bcEval + 29037 (eval.c:7156)
31 libR.dylib 0x000000010269fb81 Rf_eval + 385
32 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
33 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
34 libR.dylib 0x00000001026a6aae bcEval + 26766 (eval.c:7104)
35 libR.dylib 0x000000010269fb81 Rf_eval + 385
36 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
37 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
38 libR.dylib 0x00000001026a003b Rf_eval + 1595 (eval.c:871)
39 magrittr.so 0x00000001055f133d magrittr_pipe + 1725 (pipe.c:105)
40 libR.dylib 0x000000010266c788 do_External + 296
41 libR.dylib 0x00000001026a71b5 bcEval + 28565 (eval.c:7136)
42 libR.dylib 0x000000010269fb81 Rf_eval + 385
43 libR.dylib 0x00000001026bf9b9 R_execClosure + 2169
44 libR.dylib 0x00000001026be7a7 Rf_applyClosure + 471 (eval.c:1844)
45 libR.dylib 0x00000001026a003b Rf_eval + 1595 (eval.c:871)
46 libR.dylib 0x00000001026c3036 do_set + 2534 (eval.c:2991)
47 libR.dylib 0x000000010269fd77 Rf_eval + 887 (eval.c:823)
48 libR.dylib 0x00000001026f6e37 Rf_ReplIteration + 807 (main.c:264)
49 libR.dylib 0x00000001026f84b1 R_ReplConsole + 161 (main.c:317)
50 libR.dylib 0x00000001026f8402 run_Rmainloop + 82 (main.c:1140)
51 libR.dylib 0x00000001026f853e Rf_mainloop + 14
52 rsession 0x0000000102109c4e 0x101630000 + 11377742
53 rsession 0x00000001020dd2a6 0x101630000 + 11195046
54 rsession 0x0000000101785716 0x101630000 + 1398550
55 libdyld.dylib 0x00007fff72c17cc9 start + 1

Murray Efford

unread,
Nov 2, 2022, 1:27:00 PM11/2/22
to Scott Appleby, secr
Hi Scott
Thanks for your report. I'm out of town and it will be a few days before I can check what is going on.
Murray

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/secrgroup/c25f27cf-a89d-461c-af68-a1f466ce6d8en%40googlegroups.com.

Murray Efford

unread,
Nov 8, 2022, 2:50:44 PM11/8/22
to secr
Hi Scott
I think this was caused by a bug in sim.secr: it failed with learned-response models (b, B, bk etc.). For example,

library(secr)
test1 <- secr.test(secrdemo.b)
test2 <- secr.test(secrdemo.b)

crashed R at the second call of secr.test.

I've fixed this particular issue in the pre-release version (secr 4.5.8 2022-11-08) available as Windows binary or source from the Density website. There may be more. Your model is certainly slow (I'd start with fit = FALSE).

A couple of other points. Remember the MLE of detection parameters (g0, lambda0) use a multi-catch model, and single-catch simulations with these estimates are likely to mislead. The piped commands add an unnecessary level of obscurity for many users, including me.

Murray
Reply all
Reply to author
Forward
0 new messages