On top of that, I sometimes get segmentation fault, but I have only binary for the bug above.
It's possible that I have damaged RAM as recently I'm getting some random freezes.
I think this is impossible without furhter context, e.g. some code (preferable not the complete code, but a reduced version of it, see mcve @ stackoverflow).
Hi,
It's not reproducible as it happens randomly and actually quite rarely. I was hoping someone can direct me how to get exact asm and / or line of code for this ip address.
You can use the "usual" tools such as addr2line. If you build your binary with debug symbols (default in debug build), then it will also print the line in the source code.
Interestingly, using using the same technique and looking at previous segmentation fault, leads me to /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/slice/mod.rs:5353
5341 impl<A> SlicePartialEq<A> for [A]
5342 where A: PartialEq<A> + BytewiseEquality
5343 {
5344 fn equal(&self, other: &[A]) -> bool {
5345 if self.len() != other.len() {
5346 return false;
5347 }
5348 if self.as_ptr() == other.as_ptr() {
5349 return true;
5350 }
5351 unsafe {
5352 let size = mem::size_of_val(self);
5353 memcmp(self.as_ptr() as *const u8,
5354 other.as_ptr() as *const u8, size) == 0
5355 }
5356 }
5357 }
Edit: shouldn't there be a check for size of `other`? As it seems now, `other` can be smaller, resulting in segfault?
It's a long running process and I've had multiple crashes on other computer (different processor, code compiled with target=native for each machine). It's the first time when I started investigating it, so I don't know what caused other crashes.
I've run memory check on the main machine and it seems fine.
Invalid opcodes sounds like the processor is either jumping to a random location and trying to execute garbage, or the compiler generated opcodes which aren't valid for the processor.
You mention you use target=native when compiling, so it may even be a bug in rustc or LLVM. For example, it may try to use platform-specific instructions (SIMD, etc.) that aren't actually available.
If possible, you may want to run the program under GDB (or any other debugger). If the program hits an illegal instruction GDB should halt things and let you look at the assembly or backtrace. You mention this being a long-running process, so it may be a case of leaving it to run overnight or periodically checking it while doing other things.
rust-lang/rust#38218 may also be relevant here. In particular, this comment is promising:
@EFanZh The issue is that Rust will generate code for your CPU family, which is the Haswell family.
In theory, AVX is architecturally guaranteed on Haswell, but some CPUs like your Pentium lack it.
If you're segfaulting on linux, you should be able to get a core dump for the process. Then just load it into gdb and get a stack trace. Here's a little tutorial if you're not familiar with the workflow: