You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C API functions indicate errors by their return values. All callers of C API functions should check the return value and handle error if the return value is -1. There are two places in R-package/src/xgboost_R.cc where this is not done:
These function calls should have been wrapped with CHECK_CALL() macro to handle errors. Currently, errors from these two functions are silently discarded.
This message is misleading, as it sounds as if the error had occurred in the prediction function. In fact, the real error occurred earlier, when the model was loaded. When I inserted CHECK_CALL() macro in R-package/src/xgboost_R.cc, I got the correct error message:
Error in xgb.unserialize(modelfile) :
[03:19:04] ../src/learner.cc:864: Check failed: header == serialisation_header_:
If you are loading a serialized model (like pickle in Python) generated by older
XGBoost, please export the model by calling `Booster.save_model` from that version
first, then load it back in current version. There's a simple script for helping
the process. See:
https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html
for reference to the script, and more details about differences between saving model and
serializing.
Stack trace:
[bt] (0) /home/phcho/R/x86_64-pc-linux-gnu-library/3.6/xgboost/libs/xgboost.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x7c) [0x7f1f596f737c]
[bt] (1) /home/phcho/R/x86_64-pc-linux-gnu-library/3.6/xgboost/libs/xgboost.so(xgboost::LearnerIO::Load(dmlc::Stream*)+0x81b) [0x7f1f5980bc3b]
[bt] (2) /home/phcho/R/x86_64-pc-linux-gnu-library/3.6/xgboost/libs/xgboost.so(XGBoosterUnserializeFromBuffer+0x8c) [0x7f1f596faaec]
The text was updated successfully, but these errors were encountered:
I will write a pull request to fix this issue soon. I'd like to back-port the pull request to 1.1.x branch.
hcho3
changed the title
[BLOCKING] Two R methods discards errors from C API functions
[BLOCKING] [R] Two R methods discards errors from C API functions
Jul 24, 2020
C API functions indicate errors by their return values. All callers of C API functions should check the return value and handle error if the return value is -1. There are two places in
R-package/src/xgboost_R.cc
where this is not done:xgboost/R-package/src/xgboost_R.cc
Lines 376 to 381 in a4de2f6
xgboost/R-package/src/xgboost_R.cc
Lines 398 to 405 in a4de2f6
These function calls should have been wrapped with
CHECK_CALL()
macro to handle errors. Currently, errors from these two functions are silently discarded.In #5794, the error message was cryptic
This message is misleading, as it sounds as if the error had occurred in the prediction function. In fact, the real error occurred earlier, when the model was loaded. When I inserted
CHECK_CALL()
macro inR-package/src/xgboost_R.cc
, I got the correct error message:The text was updated successfully, but these errors were encountered: