Page MenuHome

Crash to desktop with too high number in the ocean modifier resolution viewport value
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1060 6GB/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.43

Blender Version
Broken: version: 2.92.0 Alpha, branch: master, commit date: 2020-12-19 06:25, hash: rBa5a302bd1806

Short description of error
A high value like 1200 in the resolution viewport in the ocean modifier will crash Blender to desktop.

Exact steps for others to reproduce the error
[Please describe the exact steps needed to reproduce the issue]
[Based on the default startup or an attached .blend file (as simple as possible)]

Open Blender.
Add a ocean modifier.
Type in 1200 in the resolution viewport field.
Hit enter.
Crash.

The needed files with informations:

Event Timeline

Robert Guetzkow (rjg) changed the task status from Needs Triage to Needs Information from User.EditedDec 19 2020, 6:50 PM

@Reiner Prokein (tiles) have you checked if you're running out of memory?

Checked now. There is no significant memory increasement. It immediately crashes.

Please open Blender's installation directory and double click on the blender_debug_gpu.cmd. This will start Blender in debug mode and create log files. Try to make Blender crash again. Once it crashes the Windows Explorer should open and show you up to two files, a debug log and the system information. Add them to your bug report by clicking on the upload button as shown in the screenshot below or via drag and drop. Please also upload the crash log located in C:\Users\[your username]\AppData\Local\Temp\[project name].crash.txt (or simply type %TEMP% into the path bar of the Windows Explorer).

Sure. I have updated the task and attached the files in the initial post. See blender_system_info.zip :)

Robert Guetzkow (rjg) changed the task status from Needs Information from User to Needs Triage.Dec 29 2020, 1:58 PM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Dec 30 2020, 4:29 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

The problem starts with an arithmetic overflow where the result of the operations is being cast to a size smaller than the real one.
The arithmetic overflow can be resolved with:

diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 1d62a1cce2a..034e8040a87 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -864,9 +864,10 @@ void BKE_ocean_init(struct Ocean *o,
   o->_do_chop = do_chop;
   o->_do_jacobian = do_jacobian;
 
-  o->_k = (float *)MEM_mallocN(M * (1 + N / 2) * sizeof(float), "ocean_k");
-  o->_h0 = (fftw_complex *)MEM_mallocN(M * N * sizeof(fftw_complex), "ocean_h0");
-  o->_h0_minus = (fftw_complex *)MEM_mallocN(M * N * sizeof(fftw_complex), "ocean_h0_minus");
+  o->_k = (float *)MEM_mallocN((size_t)M * (1 + (size_t)N / 2) * sizeof(float), "ocean_k");
+  o->_h0 = (fftw_complex *)MEM_mallocN((size_t)M * (size_t)N * sizeof(fftw_complex), "ocean_h0");
+  o->_h0_minus = (fftw_complex *)MEM_mallocN((size_t)M * (size_t)N * sizeof(fftw_complex),
+                                             "ocean_h0_minus");
   o->_kx = (float *)MEM_mallocN(o->_M * sizeof(float), "ocean_kx");
   o->_kz = (float *)MEM_mallocN(o->_N * sizeof(float), "ocean_kz");

But that does not solve the problem, since the amount of memory required is extremely high. Thus the malloc returns NULL.

Although we do not handle memory problems, this crash can be quite inconvenient, and this case does not appear to be something complicated to solve (perhaps it can be solved by limiting the maximum value).

So I'm confirming it as a bug.

It is indeed inconvenient. I had 20 in the box as a value, tried to type in 21 in a hurry, and ended in 2021. The next thing i saw was my desktop.

Maybe this maximum value can be coupled to a setting, maximum available ram for example. So that people with more ram can use higher values here.

Just as a reminder, we have a similar problems with other modifiers as well. This should likely be addressed in a consistent way for all modifiers.