nlmixr2 / rxode2et

https://nlmixr2.github.io/rxode2et/
1 stars 1 forks source link

Model with `est = "rxSolve"` crashes R; with `est = "focei"` works fine #39

Closed billdenney closed 5 months ago

billdenney commented 5 months ago

I have a model where I have fit a subset of the data (including a subset of the IDs), and when I do:

nlmixr2(object = prior_fit, data = full_data, est = "rxSolve")

It will crash the R session.

When I do:

nlmixr2(object = prior_fit, data = full_data, est = "focei")

it will estimate the model.

Any hints that you may be able to give to understand why it crashes in one case and works in the other? I tried removing a subject from an openly available dataset to see if the issue was that prior_fit had fewer subjects included than full_data, and that didn't appear to be it.

(As usual, I can't share the model and data at this time.)

mattfidler commented 5 months ago

Sorry. No clue from me..

On Wed, Apr 3, 2024, 10:43 AM Bill Denney @.***> wrote:

I have a model where I have fit a subset of the data (including a subset of the IDs), and when I do:

nlmixr2(object = prior_fit, data = full_data, est = "rxSolve")

It will crash the R session.

When I do:

nlmixr2(object = prior_fit, data = full_data, est = "focei")

it will estimate the model.

Any hints that you may be able to give to understand why it crashes in one case and works in the other?

— Reply to this email directly, view it on GitHub https://github.com/nlmixr2/rxode2et/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5VWXAWWXLLSSTYRGHDO3Y3QPRHAVCNFSM6AAAAABFVSLAXWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDGMRXGYZDONA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mattfidler commented 5 months ago

You could try to get a backtrack with gdb or valgrind I suppose.

On Wed, Apr 3, 2024, 1:05 PM Matthew Fidler @.***> wrote:

Sorry. No clue from me..

On Wed, Apr 3, 2024, 10:43 AM Bill Denney @.***> wrote:

I have a model where I have fit a subset of the data (including a subset of the IDs), and when I do:

nlmixr2(object = prior_fit, data = full_data, est = "rxSolve")

It will crash the R session.

When I do:

nlmixr2(object = prior_fit, data = full_data, est = "focei")

it will estimate the model.

Any hints that you may be able to give to understand why it crashes in one case and works in the other?

— Reply to this email directly, view it on GitHub https://github.com/nlmixr2/rxode2et/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5VWXAWWXLLSSTYRGHDO3Y3QPRHAVCNFSM6AAAAABFVSLAXWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDGMRXGYZDONA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

billdenney commented 5 months ago

Here's the gdb backtrace:

(for my future reference:

 R -d gdb
r
[run  the code with a SIGSEGV]
bt

)

#0  0x00007ffff7ce4e5d in SET_STRING_ELT () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#1  0x00007ffff2700669 in Rcpp::internal::string_proxy<16, Rcpp::PreserveStorage>::set (x=<optimized out>, this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
nlmixr2/nlmixr2est#2  Rcpp::internal::string_proxy<16, Rcpp::PreserveStorage>::operator= (other=..., other=..., this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/vector/string_proxy.h:58
nlmixr2/nlmixr2est#3  etSort (curEt=...) at et.cpp:506
nlmixr2/nlmixr2est#4  0x00007ffff2710d99 in etImportEventTable (inData=..., warnings=<optimized out>) at et.cpp:1491
nlmixr2/nlmixr2est#5  0x00007ffff272baaf in et_ (input=..., et__=...) at et.cpp:2294
nlmixr2/nlmixr2est#6  0x00007ffff26e6bbd in _rxode2et_et_ (inputSEXP=0x555558c26020, et__SEXP=<optimized out>) at RcppExports.cpp:46
nlmixr2/nlmixr2est#7  0x00007ffff7c522ca in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#8  0x00007ffff7c95273 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#9  0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#10 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2extra#1 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#12 0x00007ffff7ca9e2c in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#13 0x00007ffff7c397b9 in R_UnwindProtect () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2extra#3 0x00007ffff24d4fcf in Rcpp::unwindProtect (callback=0x7ffff24d40a0 <Rcpp::internal::Rcpp_protected_eval(void*)>, data=0x7ffffffd5c60)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/unwindProtect.h:74
nlmixr2/nlmixr2est#15 0x00007ffff25f74a6 in Rcpp::Rcpp_fast_eval (env=0x5555555a8888, expr=0x55555f388ac8)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h:63
nlmixr2/nlmixr2est#16 Rcpp::Function_Impl<Rcpp::PreserveStorage>::invoke (env=<optimized out>, args_=<optimized out>, this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/Function.h:118
nlmixr2/nlmixr2est#17 Rcpp::Function_Impl<Rcpp::PreserveStorage>::operator()<SEXPREC*, SEXPREC*> (t2=<synthetic pointer>: <optimized out>,
    t2=<synthetic pointer>: <optimized out>, t1=<synthetic pointer>: <optimized out>, this=0x7ffffffd5c50)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/generated/Function__operator.h:40
nlmixr2/nlmixr2est#18 _rxode2_et_ (x1=<optimized out>, x2=<optimized out>) at utilcpp.cpp:66
nlmixr2/nlmixr2est#19 0x00007ffff25839fb in et_ (input=..., et__=...) at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
nlmixr2/nlmixr2est#20 0x00007ffff258da42 in getEtRxsolve (e=...) at rxData.cpp:2252
nlmixr2/nlmixr2est#21 0x00007ffff25a8efe in updateSolveEnvPost (e=...) at rxData.cpp:2473
nlmixr2/nlmixr2est#22 0x00007ffff25ab303 in rxSolveGet_rxSolve (obj=..., sarg="ui", exact=..., lst=...) at rxData.cpp:5570
nlmixr2/nlmixr2est#23 0x00007ffff25ad79c in rxSolveGet (obj=..., arg=..., exact=...) at rxData.cpp:5783
nlmixr2/nlmixr2est#24 0x00007ffff24ce8f6 in _rxode2_rxSolveGet_try (objSEXP=0x55555cbf8640, argSEXP=<optimized out>, exactSEXP=<optimized out>) at RcppExports.cpp:859
nlmixr2/nlmixr2est#25 0x00007ffff24cea1b in _rxode2_rxSolveGet (objSEXP=0x55555cbf8640, argSEXP=0x55555c8d3c38, exactSEXP=0x55555c5d76a0) at RcppExports.cpp:867
nlmixr2/nlmixr2est#26 0x00007ffff7c522ae in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#27 0x00007ffff7c95273 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#28 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#29 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#30 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/rxode2#7 0x00007ffff7cf22c1 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#32 0x00007ffff7cf2721 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#33 0x00007ffff7c8794a in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#34 0x00007ffff7c8d2d5 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#35 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#36 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#37 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#38 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#39 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#40 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#41 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#42 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#43 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#44 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#45 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#46 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/rxode2#57 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
--Type <RET> for more, q to quit, c to continue without paging--c
nlmixr2/nlmixr2est#48 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#49 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#50 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#51 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#52 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#53 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#54 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#55 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#56 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#57 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#58 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#59 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#60 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#61 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#62 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#63 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#64 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#65 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#66 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2plot#8 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#68 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#69 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#70 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#71 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#72 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#73 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#74 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#75 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#76 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#77 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#78 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#79 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#80 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#81 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#82 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#83 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#84 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#85 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#86 0x00007ffff7cf22c1 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#87 0x00007ffff7cf2721 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#88 0x00007ffff7cf2aa2 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#89 0x00007ffff7c8f068 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#90 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#91 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/rxode2#119 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
nlmixr2/rxode2#125 0x00007ffff7ca9e2c in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#94 0x00007ffff7cae892 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#95 0x00007ffff7caa100 in Rf_eval () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#96 0x00007ffff7cdfd0a in Rf_ReplIteration () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#97 0x00007ffff7ce00a0 in ?? () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#98 0x00007ffff7ce0160 in run_Rmainloop () from /usr/lib/R/lib/libR.so
nlmixr2/nlmixr2est#99 0x000055555555509f in main ()
nlmixr2/nlmixr2est#100 0x00007ffff7957d90 in __libc_start_call_main (main=main@entry=0x555555555080 <main>, argc=argc@entry=3, argv=argv@entry=0x7fffffffe3b8) at ../sysdeps/nptl/libc_start_call_main.h:58
nlmixr2/nlmixr2est#101 0x00007ffff7957e40 in __libc_start_main_impl (main=0x555555555080 <main>, argc=3, argv=0x7fffffffe3b8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe3a8) at ../csu/libc-start.c:392
nlmixr2/nlmixr2est#102 0x00005555555550d5 in _start ()
billdenney commented 5 months ago

The versions used are:

mattfidler commented 5 months ago

The error is in this package.

mattfidler commented 5 months ago

Hi @billdenney

In #40 I added a debug statement that allows you to track which column is causing the issue. I'm not sure why it is calling this any way, but you should be able to see the j which correspond to the column number of the input dataset. (In C as opposed to R 0 is the first column).

Perhaps you will be able to see which column is causing the issue.

You could probably get around the issue by removing the string that is causing this as long as it is not used in your model (though it doesn't fix the issue).

billdenney commented 5 months ago

After installing #40, I see a lot of newSize: 22744, j: 4 before the segfault. Column 5 (using R counting from 1) is the AMT column, and column 6 is the DV column. Is there a more specific function call that I can try from R to try to isolate the issue?

The back trace looks generally similar to me (I don't think that a difference was expected).

#0  0x00007ffff7ce4e5d in SET_STRING_ELT () from /usr/lib/R/lib/libR.so
#1  0x00007ffff27005d7 in Rcpp::internal::string_proxy<16, Rcpp::PreserveStorage>::set (x=<optimized out>, this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#2  Rcpp::internal::string_proxy<16, Rcpp::PreserveStorage>::operator= (other=..., other=..., this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/vector/string_proxy.h:58
#3  etSort (curEt=...) at et.cpp:507
#4  0x00007ffff2710d19 in etImportEventTable (inData=..., warnings=<optimized out>) at et.cpp:1492
#5  0x00007ffff272ba07 in et_ (input=..., et__=...) at et.cpp:2295
#6  0x00007ffff26e6bad in _rxode2et_et_ (inputSEXP=0x55555bb37c38, et__SEXP=<optimized out>) at RcppExports.cpp:46
#7  0x00007ffff7c522ca in ?? () from /usr/lib/R/lib/libR.so
#8  0x00007ffff7c95273 in ?? () from /usr/lib/R/lib/libR.so
#9  0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#10 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#11 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#12 0x00007ffff7ca9e2c in Rf_eval () from /usr/lib/R/lib/libR.so
#13 0x00007ffff7c397b9 in R_UnwindProtect () from /usr/lib/R/lib/libR.so
#14 0x00007ffff24d4fcf in Rcpp::unwindProtect (callback=0x7ffff24d40a0 <Rcpp::internal::Rcpp_protected_eval(void*)>, data=0x7ffffffd5c60)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/unwindProtect.h:74
#15 0x00007ffff25f74a6 in Rcpp::Rcpp_fast_eval (env=0x5555555a8888, expr=0x55555f1ab2c8)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h:63
#16 Rcpp::Function_Impl<Rcpp::PreserveStorage>::invoke (env=<optimized out>, args_=<optimized out>, this=<optimized out>)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/Function.h:118
#17 Rcpp::Function_Impl<Rcpp::PreserveStorage>::operator()<SEXPREC*, SEXPREC*> (t2=<synthetic pointer>: <optimized out>,
    t2=<synthetic pointer>: <optimized out>, t1=<synthetic pointer>: <optimized out>, this=0x7ffffffd5c50)
    at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/generated/Function__operator.h:40
#18 _rxode2_et_ (x1=<optimized out>, x2=<optimized out>) at utilcpp.cpp:66
#19 0x00007ffff25839fb in et_ (input=..., et__=...) at /home/bill/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/Rcpp/storage/PreserveStorage.h:75
#20 0x00007ffff258da42 in getEtRxsolve (e=...) at rxData.cpp:2252
#21 0x00007ffff25a8efe in updateSolveEnvPost (e=...) at rxData.cpp:2473
#22 0x00007ffff25ab303 in rxSolveGet_rxSolve (obj=..., sarg="ui", exact=..., lst=...) at rxData.cpp:5570
#23 0x00007ffff25ad79c in rxSolveGet (obj=..., arg=..., exact=...) at rxData.cpp:5783
#24 0x00007ffff24ce8f6 in _rxode2_rxSolveGet_try (objSEXP=0x555555f71f80, argSEXP=<optimized out>, exactSEXP=<optimized out>) at RcppExports.cpp:859
#25 0x00007ffff24cea1b in _rxode2_rxSolveGet (objSEXP=0x555555f71f80, argSEXP=0x55555c8b8f80, exactSEXP=0x55555c5a3b58) at RcppExports.cpp:867
#26 0x00007ffff7c522ae in ?? () from /usr/lib/R/lib/libR.so
#27 0x00007ffff7c95273 in ?? () from /usr/lib/R/lib/libR.so
#28 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#29 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#30 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#31 0x00007ffff7cf22c1 in ?? () from /usr/lib/R/lib/libR.so
#32 0x00007ffff7cf2721 in ?? () from /usr/lib/R/lib/libR.so
#33 0x00007ffff7c8794a in ?? () from /usr/lib/R/lib/libR.so
#34 0x00007ffff7c8d2d5 in ?? () from /usr/lib/R/lib/libR.so
#35 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#36 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
#37 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
#38 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
#39 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
--Type <RET> for more, q to quit, c to continue without paging--c
#40 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
#41 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
#42 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
#43 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#44 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
#45 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
#46 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
#47 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#48 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
#49 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
#50 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
#51 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#52 0x00007ffff7caa6a4 in ?? () from /usr/lib/R/lib/libR.so
#53 0x00007ffff7caa988 in ?? () from /usr/lib/R/lib/libR.so
#54 0x00007ffff7c95d42 in ?? () from /usr/lib/R/lib/libR.so
#55 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#56 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#57 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#58 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#59 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#60 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#61 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#62 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#63 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#64 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#65 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#66 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#67 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#68 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#69 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#70 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#71 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#72 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#73 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#74 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#75 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#76 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#77 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#78 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#79 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#80 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#81 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#82 0x00007ffff7c9acfd in ?? () from /usr/lib/R/lib/libR.so
#83 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#84 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#85 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#86 0x00007ffff7cf22c1 in ?? () from /usr/lib/R/lib/libR.so
#87 0x00007ffff7cf2721 in ?? () from /usr/lib/R/lib/libR.so
#88 0x00007ffff7cf2aa2 in ?? () from /usr/lib/R/lib/libR.so
#89 0x00007ffff7c8f068 in ?? () from /usr/lib/R/lib/libR.so
#90 0x00007ffff7ca9d00 in Rf_eval () from /usr/lib/R/lib/libR.so
#91 0x00007ffff7cabd86 in ?? () from /usr/lib/R/lib/libR.so
#92 0x00007ffff7cacbb5 in Rf_applyClosure () from /usr/lib/R/lib/libR.so
#93 0x00007ffff7ca9e2c in Rf_eval () from /usr/lib/R/lib/libR.so
#94 0x00007ffff7cae892 in ?? () from /usr/lib/R/lib/libR.so
#95 0x00007ffff7caa100 in Rf_eval () from /usr/lib/R/lib/libR.so
#96 0x00007ffff7cdfd0a in Rf_ReplIteration () from /usr/lib/R/lib/libR.so
#97 0x00007ffff7ce00a0 in ?? () from /usr/lib/R/lib/libR.so
#98 0x00007ffff7ce0160 in run_Rmainloop () from /usr/lib/R/lib/libR.so
#99 0x000055555555509f in main ()
#100 0x00007ffff7957d90 in __libc_start_call_main (main=main@entry=0x555555555080 <main>, argc=argc@entry=3, argv=argv@entry=0x7fffffffe3b8) at ../sysdeps/nptl/libc_start_call_main.h:58
#101 0x00007ffff7957e40 in __libc_start_main_impl (main=0x555555555080 <main>, argc=3, argv=0x7fffffffe3b8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe3a8) at ../csu/libc-start.c:392
#102 0x00005555555550d5 in _start ()
billdenney commented 5 months ago

I traced to the individual that was causing the problem, and it seems that it could be related to NA values in the TIME column. I tried to make a reprex with theophylline, and I couldn't immediately cause the issue there.

mattfidler commented 5 months ago

Can you try looking at the columns that rxode2 may see:

tmp <- rxode2::etTrans(data, rxode2::as.rxUi(model)$simulationModel)
head(tmp)
mattfidler commented 5 months ago

I traced to the individual that was causing the problem, and it seems that it could be related to NA values in the TIME column. I tried to make a reprex with theophylline, and I couldn't immediately cause the issue there.

I think this is not really the issue. If it was, it would not be related to string handling.

billdenney commented 5 months ago

I have a 2-row minimal dataset that will crash R. With that minimal example, I have the following:

> tmp <- rxode2::etTrans(d_mod_new, rxode2::as.rxUi(model)$simulationModel)
head(tmp)
[Detaching after vfork from child process 1854110]
[Detaching after fork from child process 1854112]
using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’

Error: no rows in event table or input data
In addition: Warning messages:
1: IDs without observations dropped: ZN-c3-001-0103-045
2: missing 'TIME' values do not make sense (ignored)
> tmp
Error: object 'tmp' not found

When I run etTrans on all of the data for the subject who crashes R, the only oddity that I see is missing TIME data.

When I run the model on the data after processing it with etTrans() (i.e. the tmp data from above), R does not crash. When I run it on the original data without preprocessing, it still crashes.

mattfidler commented 5 months ago

I have changed #40 to count the number of non-NA times instead of the length of times to see if that fixes your issue.

Without a reproducible example, though I cannot test for this case.

(Hopefully it fixes it; If so I will remove the print statement.

billdenney commented 5 months ago

Here is the reprex:

model <-
function() {
    ini({
        lfdose_max <- -0.1
        lfdose_50 <- 1
        lktr <- 0.1
        lka <- -1
        lcl <- 1.1
        lvc <- 1.1
        lvp <- 1.1
        lq <- 1.1
        cl_covar <- -1
        propSd <- 0.1
        addSd <- 1
        iiv_fdose_max ~ 0
        iiv_ktr ~ 0
        iiv_ka ~ 0.1
        iiv_cl ~ 0.1
        iiv_vc ~ 0.1
    })

    model({
        fdose_max <- exp(lfdose_max + iiv_fdose_max)
        fdose_50 <- exp(lfdose_50)
        fdose <- 1 + fdose_max * DOSE/(fdose_50 + DOSE)
        fdepot <- fdose
        ktr <- exp(lktr + iiv_ktr)
        ka <- exp(lka + iiv_ka)
        cl <- exp(lcl + COVAR * cl_covar + iiv_cl)
        vc <- exp(lvc + iiv_vc)
        vp <- exp(lvp)
        q <- exp(lq)
        kel <- cl/vc
        k12 <- q/vc
        k21 <- q/vp
        d/dt(depot) <- -ktr * depot
        d/dt(transit) <- -ka * transit + ktr * fdepot * depot
        d/dt(central) <- ka * transit - kel * central - k12 *
            central + k21 * peripheral1
        d/dt(peripheral1) <- k12 * central - k21 * peripheral1
        cc <- 1000 * central/vc
        cc ~ prop(propSd) + add(addSd)
    })

}

mydata <-
  data.frame(
    ID = "A",
    TIME = c(738.9333333, NA),
    CMT = c("depot", "central"),
    AMT = c(300, NA),
    EVID = c(1, 0),
    DOSE = 300,
    COVAR = 1
  )
d_sim_crash <- nlmixr(object = model, data = mydata, est = "rxSolve")
mattfidler commented 5 months ago

Thanks Bill. It is fixed.

library(nlmixr2)
#> Loading required package: nlmixr2data

model <-
  function() {
    ini({
      lfdose_max <- -0.1
      lfdose_50 <- 1
      lktr <- 0.1
      lka <- -1
      lcl <- 1.1
      lvc <- 1.1
      lvp <- 1.1
      lq <- 1.1
      cl_covar <- -1
      propSd <- 0.1
      addSd <- 1
      iiv_fdose_max ~ 0
      iiv_ktr ~ 0
      iiv_ka ~ 0.1
      iiv_cl ~ 0.1
      iiv_vc ~ 0.1
    })

    model({
      fdose_max <- exp(lfdose_max + iiv_fdose_max)
      fdose_50 <- exp(lfdose_50)
      fdose <- 1 + fdose_max * DOSE/(fdose_50 + DOSE)
      fdepot <- fdose
      ktr <- exp(lktr + iiv_ktr)
      ka <- exp(lka + iiv_ka)
      cl <- exp(lcl + COVAR * cl_covar + iiv_cl)
      vc <- exp(lvc + iiv_vc)
      vp <- exp(lvp)
      q <- exp(lq)
      kel <- cl/vc
      k12 <- q/vc
      k21 <- q/vp
      d/dt(depot) <- -ktr * depot
      d/dt(transit) <- -ka * transit + ktr * fdepot * depot
      d/dt(central) <- ka * transit - kel * central - k12 *
        central + k21 * peripheral1
      d/dt(peripheral1) <- k12 * central - k21 * peripheral1
      cc <- 1000 * central/vc
      cc ~ prop(propSd) + add(addSd)
    })

  }

mydata <-
  data.frame(
    ID = "A",
    TIME = c(738.9333333, NA),
    CMT = c("depot", "central"),
    AMT = c(300, NA),
    EVID = c(1, 0),
    DOSE = 300,
    COVAR = 1
  )
d_sim_crash <- nlmixr(object = model, data = mydata, est = "rxSolve")
#> ℹ the following etas are removed from the model since their initial estimates are zero: iiv_fdose_max, iiv_ktr
#> Warning: while importing the dataset, some times are NA and ignored

print(d_sim_crash)
#> ── Solved rxode2 object ──
#> ── Parameters ($params): ──
#>  lfdose_max   lfdose_50        lktr         lka         lcl         lvc 
#> -0.10000000  1.00000000  0.10000000 -1.00000000  1.10000000  1.10000000 
#>         lvp          lq    cl_covar      propSd       addSd      iiv_ka 
#>  1.10000000  1.10000000 -1.00000000  0.10000000  1.00000000  0.32102171 
#>      iiv_cl      iiv_vc 
#>  0.05252124 -0.25138275 
#> ── Initial Conditions ($inits): ──
#>       depot     transit     central peripheral1 
#>           0           0           0           0 
#> ── First part of data (object): ──
#> # A tibble: 0 × 23
#> # ℹ 23 variables: time <dbl>, fdose_max <dbl>, fdose_50 <dbl>, fdose <dbl>,
#> #   fdepot <dbl>, ktr <dbl>, ka <dbl>, cl <dbl>, vc <dbl>, vp <dbl>, q <dbl>,
#> #   kel <dbl>, k12 <dbl>, k21 <dbl>, cc <dbl>, ipredSim <dbl>, sim <dbl>,
#> #   depot <dbl>, transit <dbl>, central <dbl>, peripheral1 <dbl>, DOSE <dbl>,
#> #   COVAR <dbl>

Created on 2024-04-05 with reprex v2.0.2

billdenney commented 5 months ago

I just verified that it works for me, too. Thanks!