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

Opening NetCDF makes computer crash #55811

Open
2 tasks done
EmileSonneveld opened this issue Jan 10, 2024 · 8 comments
Open
2 tasks done

Opening NetCDF makes computer crash #55811

EmileSonneveld opened this issue Jan 10, 2024 · 8 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption Mesh Related to general mesh layer handling (not specific data formats) Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)

Comments

@EmileSonneveld
Copy link

What is the bug or the crash?

When I open this file with QGIS, my whole user session crashes. I get a black screen and need to log in again.
I think it is due to an over de top amount of RAM being allocated:
https://emilesonneveld.be/misc/Sentinel2_makes_linux_user_session_crash.nc (Save any work before opening this NetCDF)

Steps to reproduce the issue

  1. Open the attached file: https://emilesonneveld.be/misc/Sentinel2_makes_linux_user_session_crash.nc
  2. Wait
  3. Experience a crash

Versions

3.22.4-Białowieża

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

I made a new profile and added the standard OpenStreetMap as background. Still got the crash
I run Ubuntu with kernel 6.2.0-39-generic
My colleague runs Linux mint and has the same problem

@EmileSonneveld EmileSonneveld added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 10, 2024
@agiudiceandrea
Copy link
Contributor

@EmileSonneveld, thanks for reporting. QGIS 3.22 is no longer supported. May you please actually try if the issue occurs also using a currently supported QGIS version (QGIS 3.34.2, QGIS 3.28.14) and provide the full version info ("In the QGIS Help menu -> About, click in the table, Ctrl+A and then Ctrl+C. Finally paste here. Do not make a screenshot.") as requested in the issue report form?

@agiudiceandrea agiudiceandrea added Data Provider Related to specific vector, raster or mesh data providers Crash/Data Corruption labels Jan 10, 2024
@rouault
Copy link
Contributor

rouault commented Jan 10, 2024

The huge RAM consumption arises when opening the file with "Add mesh layer" . It works fine with "Add raster layer" (using GDAL netCDF driver)

@rouault
Copy link
Contributor

rouault commented Jan 10, 2024

@PeterPetrik Debugging this, I see QGIS spends its time in MDAL::DriverGdal::initFaces(). On this dataset where width = 16831 and height = 12992, and my understanding of "typedef std::vector Faces;" and "typedef std::vector<size_t> Face;", my estimate of the minimum amount of RAM required is 16830 * 12991 * (sizeof(size_t) + sizeof(void*) + 4 * sizeof(size_t)) ~= 10 GB, and probably more due to memory fragmentation given we allocate lots of Face elements one at a time.
As adding piece-wise loading of data is probably a difficult undertaking, it seems that MDAL should bail out on a GDAL dataset beyond some dimension, likely correlated to available RAM (there's a GDAL CPLGetUsablePhysicalRAM() function for that)

@agiudiceandrea agiudiceandrea added the Mesh Related to general mesh layer handling (not specific data formats) label Jan 10, 2024
@EmileSonneveld
Copy link
Author

Loading it without the mesh indeed avoids the problem! Can I disable mesh creation by default in QGIS? Or configure the NetCDF to avoid mesh creation?
The ram usage could indeed be 10Gb+. That's about the amount that was free at time of crash.

@PeterPetrik
Copy link
Contributor

Hi and thanks for report and debugging: created MDAL issue for this lutraconsulting/MDAL#476

@agiudiceandrea agiudiceandrea added Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...) and removed Data Provider Related to specific vector, raster or mesh data providers labels Jan 11, 2024
@EmileSonneveld
Copy link
Author

In 3.34.2-Prizren, only QGIS crashes without error message. Which is quite better. It allows to try again without the mesh

@JaqucesT
Copy link

Opening this file in 3.34.3 memory consumption rises till 36 GB in steps and then it starts rising in a linear way as if there is a memory leak. When QGis reaches 50 GB of memory consumption i get a "Bad allocation" error, but the program stays alive. Removing this layer then takes a long time where you can see memory consumption drop to some normal 350 MB.

@rouault
Copy link
Contributor

rouault commented Mar 11, 2024

Another instance of that issue in #56786 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption Mesh Related to general mesh layer handling (not specific data formats) Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)
Projects
None yet
Development

No branches or pull requests

5 participants