Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow: Error : C stack usage * is too close to the limit #48

Closed
appelmar opened this issue Nov 2, 2021 · 9 comments
Closed

Comments

@appelmar
Copy link
Owner

appelmar commented Nov 2, 2021

Occasionally, creating a data cube crashes with a stack overflow and/or a corrupt result file. Unfortunately, this happens mostly after performing several operations but there is no reproducible example yet. Some tests to find out the source include the following:

  1. The behavior was never observed outside of R (i.e. when using the simple gdalcubes command line client to create cubes).
  2. Disabling the progress bar does not solve the issue
  3. Using RcppThread for creating C++ threads does not solve the issue
@appelmar
Copy link
Owner Author

appelmar commented Nov 2, 2021

It seems that increasing the maximum stack size with ulimit -s can solve the issue

@appelmar
Copy link
Owner Author

appelmar commented Feb 6, 2022

This might be caused by the GDAL error handler defined by the sf package. The GDAL error handler (set with
CPLSetErrorHandler) might be called from threads created by gdalcubes but the error handler calls Rf_warning() (see https://github.com/r-spatial/sf/blob/5dde39c8261dc6b202e6cde9d41ad3bf0f46aa3a/src/gdal.cpp#L29), which is not thread-safe. However, a single-thread test, where all computations run in the main thread should clarify further.

@appelmar
Copy link
Owner Author

appelmar commented Feb 8, 2022

Commit e79f4ed fixes the issue by calling CPLPushErrorHandler() before threads are started (or as a first call within a thread). However, the issue will remain open until changes are merged into master.

@appelmar
Copy link
Owner Author

appelmar commented Feb 9, 2022

@edzer

@edzer
Copy link

edzer commented Feb 9, 2022

Fantastic news that you resolved this!!

@edzer
Copy link

edzer commented Feb 9, 2022

@gilbertocamara

@edzer
Copy link

edzer commented Feb 23, 2022

Time for a new CRAN release? @rhijmans this might also be of interest to terra development.

@appelmar
Copy link
Owner Author

Yes, planning to submit to CRAN next week

@appelmar
Copy link
Owner Author

appelmar commented Mar 8, 2022

v0.6.0 is now on CRAN (binary package builds may take some more days)

@appelmar appelmar closed this as completed Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants