Compilation error signal: 9, sigkill: kill
**
I have a function with 30000 enum match items, which directly reports an error when compiling. "(signal: 9, sigkill: kill)", and the code is roughly as follows
match (ref_a , ref_b , ref_c) {
(Int8(val_a), Int8(val_b) , Int8(val_c) ) => self.group(val_a,val_b,val_c ),
.......(30000 combinations)
}
process didn't exit successfully: rustc ................................. (signal: 9, sigkill: kill)
Meta
rustc --version --verbose:
rustc 1.62.0-nightly (f4a7ce997 2022-04-08)
binary: rustc
commit-hash: f4a7ce997a1d7546d2b737f8b87d36907bcea2ad
commit-date: 2022-04-08
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.0
Linux 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Machine memory 32G
Backtrace
process didn't exit successfully: `rustc --crate-name a_query --edition=2021 query/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="simd"' -C metadata=9a9ac94ad6ed1e61 -C extra-filename=-9a9ac94ad6ed1e61
Perhaps the compiler is running out of memory and getting killed by the OOM killer.
I monitored the memory usage. It should not be. My memory is 32g, basically free
Can you upload a single rust file that fails to compile on your system? You can use https://gist.github.com/ as a pastebin.
Sorry, the project is too big to be separated
Can you get a backtrace to this by running the build under gdb then running backtrace when the SIGKILL hits?
I can easily imagine this compilation using 32 GB or more, question is why
You should check dmesg and journal if there are any mentions of killed process.
I mean...
I'm not exactly surprised that Rustc is taking more than 32 gigabytes of memory to compile 30000 patterns in a single match statement.
Why need 30000 patterns in a single match.Because I can't find a suitable way for the following modes: “Association type cannot dyn”
pub trait A: Into<AImpl> {
//**Association type:**
type Item<'a>: Scalar<'a> where Self: 'a;
}
pub enum AImpl {
Int8(P), // P impl trait A
Int16(D), // D impl trait A
//20 Item
}
fn func<'a, T1: A, T2: A, T3: A, T4: A>(a: &'a T1, b: &'a T2, c: &'a T3, d: &'a T4) {
}
//
// There is a better way??
//
fn call_func(a:AImpl,b:AImpl,c:AImpl,d:AImpl ) {
match (a,b,c,d) {
( AImpl::Int8(v1),AImpl::Int8(v2),AImpl::Int8(v3),AImpl::Int8(v4),) => {
func( v1,v2,v3,v4)
}
... //30000 match
}
}
geez the code size will probably be huge with that as well :cold_sweat: @Amdahl-rs
Instead of type Item = dyn SomeTrait; you maybe meant type Item = Box<dyn SomeTrait>?
Or if you really want to allow unsized types (and with that also dyn Trait types) for the associated type you have to do
type Item<'a>: Scalar<'a> + ?Sized where Self: 'a
And also where is the Scalar trait defined? Is it in your crate or an external one? If it is external: which one?
Thanks: @Seppel3210 The main problems are: Association type trait, which is caused by using box < dyn sometrait >