kaskr / adcomp

AD computation with Template Model Builder (TMB)
Other
178 stars 81 forks source link

Out-of-bounds error not detected with gdbsource debugger #367

Closed iperedaagirre closed 2 years ago

iperedaagirre commented 2 years ago

Description:

I'm trying to work on a model that used to work and I've done a few modifications on. When trying to run the MakeADFun command, which looks like this: MakeADFun(Data, parameters, DLL=ModelName,hessian=TRUE,random=c("U","R")) , R crashes and the terminal gives me the following error: TMB has received an error from Eigen. The following condition was not met: EIGEN_IMPLIES(RowsAtCompileTime!=Dynamic,rows==RowsAtCompileTime) && EIGEN_IMPLIES(ColsAtCompileTime!=Dynamic,cols==ColsAtCompileTime) && EIGEN_IMPLIES(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic,rows<=MaxRowsAtCompileTime) && EIGEN_IMPLIES(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic,cols<=MaxColsAtCompileTime) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array." Please check your matrix-vector bounds etc., or run your program through a debugger. Aborted (core dumped)

According to the TMB guide, seems like an Out-of-bounds error, so I proceed to use gdbsource("my_project.R"), changing the compile line in my R file to add the required "-O0 -g" parameters, but it returns Program returned without errors, so I cannot find the error on my .cpp code.

Reproducible Steps:

  1. Try to run the model normally with MakeADFun
  2. Output: Out-of-bounds error
  3. Add -O0 -g parameters to compile
  4. Run gdbsource("my_project.R")
  5. Output: Program returned without errors

Current Output:

  1. TMB has received an error from Eigen. The following condition was not met: EIGEN_IMPLIES(RowsAtCompileTime!=Dynamic,rows==RowsAtCompileTime) && EIGEN_IMPLIES(ColsAtCompileTime!=Dynamic,cols==ColsAtCompileTime) && EIGEN_IMPLIES(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic,rows<=MaxRowsAtCompileTime) && EIGEN_IMPLIES(ColsAtCompileTime==Dynamic && MaxColsAtCompileTime!=Dynamic,cols<=MaxColsAtCompileTime) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array." Please check your matrix-vector bounds etc., or run your program through a debugger. Aborted (core dumped)

  2. Program returned without errors

Expected Output:

Normal execution on the first case, or line of error for the second case.

TMB Version:

1.7.22

R Version:

3.6.2

Operating System:

Ubuntu 16.04.6 LTS

kaskr commented 2 years ago

I agree that this is not as expected but without a reproducible example not much I can do... Some explanations:

In any case, this is more appropriate for the tmb-users list. Thanks

iperedaagirre commented 2 years ago

Thank you! I've tried interactive run of gdbsource, and didn't make any difference and wouldn't tell me either where the error was, I reinstalled both R and TMB and didn't solve anything either. I tried in two other computers and I had the same error in one of both, but got it to work in the second one. Now it does output the lines where the errors are when running gdbsource. Nothing that I could tell I did differently, but it kind of "solved" on its own...

I'm sorry for the inconveniences, and thank you