Description
Code
I tried this code:
#[macro_use]
extern crate glium;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let events_loop = glium::glutin::event_loop::EventLoop::new();
let window = glium::glutin::window::WindowBuilder::new().with_inner_size(glium::glutin::dpi::LogicalSize::new(1600.0, 900.0))
.with_title("Modern Era");
let context = glium::glutin::ContextBuilder::new().with_depth_buffer(24).
with_stencil_buffer(8).
with_vsync(true);
let display = glium::Display::new(window, context, &events_loop).unwrap();
let texture_array = glium::texture::SrgbTexture2dArray::empty_with_format(
&display,
glium::texture::SrgbFormat::U8U8U8U8,
glium::texture::MipmapsOption::NoMipmap,
2048,
2048,
100,
).unwrap();
println!("Success");
Ok(())
}
Cargo.toml:
[package]
name = "glium-repro"
version = "0.1.0"
edition = "2021"
[profile.dev.package."*"]
opt-level = 2
[dependencies]
glium = { version = "0.31" }
rand = "*"
I expected to see this happen: The program should print 'Success', and not any opengl-errors.
Instead, this happened:
glium fails while creating the texture array. Program output is:
Debug message with high or medium severity: `GL_INVALID_OPERATION error generated. TexStorage is not valid with the default texture.`.
Please report this error: https://github.com/glium/glium/issues
Backtrace:
<backtrace included further down in this report>
Version it worked on
This worked in rust nightly 2024-05-03, and is broken on 2024-05-04. It also works in 1.78 stable.
Most recent version it works on is befabbc .
Version with regression
Using cargo-bisect-rustc, the regressed commit is identified as d2d24e3 .
rustc --version --verbose
:
rustc 1.80.0-nightly (d2d24e395 2024-05-03)
binary: rustc
commit-hash: d2d24e395a1e4fcee62ca17bf4cbddb1f903af97
commit-date: 2024-05-03
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Backtrace
1 - 0x6516c3b9ff94
_ZN9backtrace9backtrace9libunwind5trace17hf248cdcd846796d8E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.71/src/backtrace/libunwind.rs:105
_ZN9backtrace9backtrace20trace_unsynchronized17h292c4323b8988101E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.71/src/backtrace/mod.rs:66
_ZN9backtrace9backtrace5trace17hb9448dc924516100E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.71/src/backtrace/mod.rs:53
2 - 0x6516c3ba90fc
_ZN5glium7context22default_debug_callback17h820be32fc85eac51E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.31.0/src/context/mod.rs:847
3 - 0x6516c3b684db
_ZN4core3ops8function5FnMut8call_mut17h649580c94d6a923cE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/core/src/ops/function.rs:166
4 - 0x6516c3ba95a7
_ZN89_$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnMut$LT$Args$GT$$GT$8call_mut17hf79f41c962be25b6E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/alloc/src/boxed.rs:2029
_ZN5glium7context19init_debug_callback16callback_wrapper17h26c632e8cb0748b0E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.31.0/src/context/mod.rs:934
5 - 0x7d9f66e6b352
6 - 0x7d9f66e6b49e
7 - 0x7d9f673e042a
8 - 0x6516c3abbe0e
_ZN5glium2gl2Gl12TexStorage3D17h28216eb18456f005E at /home/anders/glium-repro/target/debug/build/glium-7f35b15b862f3f1b/out/gl_bindings.rs:8477
_ZN5glium7texture3any11new_texture17h98acd018f50cd1f7E at /home/anders/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.31.0/src/texture/any.rs:284
9 - 0x6516c3b98537
_ZN5glium7texture8textures20srgb_texture2d_array18SrgbTexture2dArray17empty_with_format17h8c9d28809a0be8f5E at /home/anders/glium-repro/target/debug/build/glium-7f35b15b862f3f1b/out/textures.rs:16545
10 - 0x6516c3b88c11
_ZN11glium_repro4main17h3bcd047fe296b824E at /home/anders/glium-repro/src/main.rs:16
11 - 0x6516c3b692eb
_ZN4core3ops8function6FnOnce9call_once17h079ca7a5685dec0fE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/core/src/ops/function.rs:250
12 - 0x6516c3acccae
_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hea3db9391110e274E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/sys_common/backtrace.rs:155
13 - 0x6516c3ae5bb1
_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h1f51f2b82e09131aE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/rt.rs:159
14 - 0x6516c3cd880d
_ZN4core3ops8function5impls72_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$9call_once17h02edd9f2724c8c4dE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/core/src/ops/function.rs:284
_ZN3std9panicking3try7do_call17ha9443b2257b1aaeaE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panicking.rs:559
_ZN3std9panicking3try17hd6ff62c6dbf865a7E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panicking.rs:523
_ZN3std5panic12catch_unwind17h0087e2d5e1960dbeE at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panic.rs:149
_ZN3std2rt19lang_start_internal28_$u7b$$u7b$closure$u7d$$u7d$17hee1b5005adae4868E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/rt.rs:141
_ZN3std9panicking3try7do_call17h46290ab743cb5fc8E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panicking.rs:559
_ZN3std9panicking3try17hfc87b8c0e54c70f4E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panicking.rs:523
_ZN3std5panic12catch_unwind17h1a1ad9cc9e161db7E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/panic.rs:149
_ZN3std2rt19lang_start_internal17h37ad571483bb8f84E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/rt.rs:141
15 - 0x6516c3ae5b8a
_ZN3std2rt10lang_start17h8ad6b720372797b1E at /rustc/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97/library/std/src/rt.rs:158
16 - 0x6516c3b88dee
main at <unknown>:??
17 - 0x7d9f69a28150
__libc_start_call_main at ./csu/../sysdeps/nptl/libc_start_call_main.h:58
18 - 0x7d9f69a28209
__libc_start_main_impl at ./csu/../csu/libc-start.c:360
19 - 0x6516c3ab1735
_start at <unknown>:??
20 - 0x0
Further information
The problem was initially discovered in a large 3D-application which was observed to not render textures if compiled with a rust 'nightly' compiler from 2024-05-04 or later. The application worked apart from this.
The problem goes away if the [profile.dev.package.*]-section is omitted from Cargo.toml. I.e, it seems the problem is triggered by having release-compiled crates in the same binary as debug-compiled.
The problem also goes away if glium is upgraded to the latest version. I have not been able to determine if this just somehow hides the problem, or if it outright fixes it. Porting the repro case to newer glium is easy, but porting the actual faulting application would be more work.
It may well be that some UB in glium is triggering the problem. But I thought I'd write this issue anyway, if this is an actual obscure compiler bug, it would be a shame if it hit stable and caused problems.
Are the changes in d2d24e3 such that they would be likely to uncover UB?
Repro-repo: https://github.com/avl/glium-repro
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged