rust icon indicating copy to clipboard operation
rust copied to clipboard

Compilation error signal: 9, sigkill: kill

Open Amdahl-rs opened this issue 3 years ago • 7 comments

**

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 

Amdahl-rs avatar Aug 05 '22 09:08 Amdahl-rs

Perhaps the compiler is running out of memory and getting killed by the OOM killer.

Noratrieb avatar Aug 05 '22 11:08 Noratrieb

I monitored the memory usage. It should not be. My memory is 32g, basically free

Amdahl-rs avatar Aug 05 '22 11:08 Amdahl-rs

Can you upload a single rust file that fails to compile on your system? You can use https://gist.github.com/ as a pastebin.

5225225 avatar Aug 05 '22 11:08 5225225

Sorry, the project is too big to be separated

Amdahl-rs avatar Aug 05 '22 16:08 Amdahl-rs

Can you get a backtrace to this by running the build under gdb then running backtrace when the SIGKILL hits?

saethlin avatar Aug 06 '22 05:08 saethlin

I can easily imagine this compilation using 32 GB or more, question is why

saethlin avatar Aug 06 '22 05:08 saethlin

You should check dmesg and journal if there are any mentions of killed process.

mati865 avatar Aug 06 '22 07:08 mati865

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.

gimbling-away avatar Aug 06 '22 10:08 gimbling-away

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
    }
}

Amdahl-rs avatar Aug 06 '22 12:08 Amdahl-rs

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

Seppel3210 avatar Aug 07 '22 20:08 Seppel3210

And also where is the Scalar trait defined? Is it in your crate or an external one? If it is external: which one?

Seppel3210 avatar Aug 07 '22 20:08 Seppel3210

Thanks: @Seppel3210 The main problems are: Association type trait, which is caused by using box < dyn sometrait >

Amdahl-rs avatar Aug 08 '22 01:08 Amdahl-rs