When using VSCode, the intellisense starts running and blocks the entire VM, and then I have to close it.
I deleted the target folder. I then run cargo build and it builds the dependencies but when it starts to build my project everything freezes again and the notebook starts getting hot.
I have 8gb and opened only the project to compile on terminal, not even vscode opened.
I traced the problem to this line:
changing
gl::BufferData(
gl::PIXEL_UNPACK_BUFFER,
texture_size[i as usize],
ffmpeg_decoded_packet.data(i.into()).as_ptr() as *mut libc::c_void,
gl::STREAM_DRAW,
);
to
gl::BufferData(
gl::PIXEL_UNPACK_BUFFER,
(texture_size[i as usize] as usize * std::mem::size_of::<f32>()) as isize
ffmpeg_decoded_packet.data(i.into()).as_ptr() as *const libc::c_void,
gl::STREAM_DRAW,
);
makes the crash happen. Problem is in this line (texture_size[i as usize] as usize * std::mem::size_of::<f32>()) as isize. With texture_size[i as usize], it does not crash
It sounds like a bug in the compiler might be causing it to go into an infinite loop and use more and more memory until it gets killed.
If it is a compiler bug, one useful first step is to check which versions it affects. Does it show up if you use the latest beta or nightly toolchain? How about an older stable toolchain? Once you know roughly what version(s) are affected, you could report it to the Rust issue tracker, and/or use cargo-bisect-rustc to narrow down the regression range even further.
gl::BufferData(
gl::PIXEL_UNPACK_BUFFER,
(texture_size[i as usize] as usize * std::mem::size_of::<f32>()) as isize
ffmpeg_decoded_packet.data(i.into()).as_ptr() as *const libc::c_void,
gl::STREAM_DRAW,
);
the missing comma on (texture_size[i as usize] as usize * std::mem::size_of::<f32>()) as isize causes this. With the comma everything works ok.
error: expected one of `!`, `(`, `)`, `,`, `.`, `::`, `<`, or `?`, found `vertices`
--> src/main.rs:68:13
|
67 | (vertices.len() * std::mem::size_of::<f32>()) as gl::types::GLsizeiptr
| - expected one of 8 possible tokens
| ___________________________________________________________________________________|
| |
68 | | vertices.as_ptr() as *const gl::types::GLvoid, // pointer to data
| | | ^^^^^^^^ unexpected token
The following seems to be a minimal test case. Note that lines 3 and 4 must have at least 29 columns of leading whitespace in order to reproduce the bug.
I took the code from the example above, pasted it into a main function, and found that I was able to reproduce the problem. Then I removed and simplified pieces of it until I couldn't reduce it any further.
After updating to the latest nightly, I can no longer reproduce the problem. I haven't yet bisected to find out when it was fixed, but it looks like it was within the past month or so.
I can reproduce the bug in:
rustc 1.47.0-beta.3 (aa30bf344 2020-09-10)
rustc 1.48.0-nightly (e2be5f568 2020-09-09)
But not in:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
rustc 1.49.0-nightly (c71248b70 2020-10-11)
So the fix must have been backported to the 1.47 branch.