JAVA ASM conditionals - java-bytecode-asm

I want to create following java method using JAVA ASM.
public Object myeq(String one) {
if (one.equalsIgnoreCase("ABC")) {
return this.one;
} else if (one.equalsIgnoreCase("BCD")) {
return this.two;
} else {
return this.three;
}
}
Following is the -p output for the sample
public java.lang.Object myeq(java.lang.String);
descriptor: (Ljava/lang/String;)Ljava/lang/Object;
flags: (0x0001) ACC_PUBLIC
Code:
stack=2, locals=2, args_size=2
0: aload_1
1: ldc #2 // String ABC
3: invokevirtual #3 // Method java/lang/String.equalsIgnoreCase:(Ljava/lang/String;)Z
6: ifeq 14
9: aload_0
10: getfield #4 // Field one:Ljava/lang/String;
13: areturn
14: aload_1
15: ldc #5 // String BCD
17: invokevirtual #3 // Method java/lang/String.equalsIgnoreCase:(Ljava/lang/String;)Z
20: ifeq 28
23: aload_0
24: getfield #6 // Field two:Ljava/lang/Float;
27: areturn
28: aload_0
29: getfield #7 // Field three:I
32: invokestatic #8 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
35: areturn
LineNumberTable:
line 14: 0
line 15: 9
line 16: 14
line 17: 23
line 19: 28
StackMapTable: number_of_entries = 2
frame_type = 14 /* same */
frame_type = 13 /* same */
As i am new to ASM would want to know how do i move ahead with doing this and if there are any sample that could guide me on the same.

Related

error STATUS_STACK_BUFFER_OVERRUN out of nowhere [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
The recent days I've been encountering this
thread panicked while panicking. aborting.
error: test failed, to rerun pass '--lib'
Caused by:
process didn't exit successfully: `C:\Users\Windows10\Projects\Rust\current\rs-sb3\target\debug\deps\sb3-44311f04214ba6d4.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
Some day when I open my laptop, the code will just unit test perfectly fine. But after some modification to the code then the error will appear. If I tried to comment out the suspect code then the error will still come up. After awhile I cloned the repo to my pc then it works. Some modification later, the error came up.
This is my repo. I cannot provide the exact code due to my zero understanding of the problem.
It's a bug in assert_eq_sorted.
I managed to reduce it down to the following minimal reproducible example:
#[cfg(test)]
mod test {
use pretty_assertions_sorted::assert_eq_sorted;
use serde_json::json;
#[test]
fn double_panic() {
assert_eq_sorted!(json!({"a":0}), json!(null));
}
}
When run with cargo test -- --nocapture:
running 1 test
thread 'test::double_panic' panicked at 'Failed to parse Debug output, err: Failed to consume all of string!
Value:
Object
Rest:
" {\"a\": Number(0)}"', /home/finomnis/.cargo/registry/src/github.com-1ecc6299db9ec823/pretty_assertions_sorted-1.2.0/src/lib.rs:101:17
stack backtrace:
0: 0x56291e9c8e3d - std::backtrace_rs::backtrace::libunwind::trace::h8217d0a8f3fd2f41
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x56291e9c8e3d - std::backtrace_rs::backtrace::trace_unsynchronized::h308103876b3af410
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x56291e9c8e3d - std::sys_common::backtrace::_print_fmt::hc208018c6153605e
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
3: 0x56291e9c8e3d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf89a7ed694dfb585
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
4: 0x56291e9ebc1c - core::fmt::write::h21038c1382fe4264
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
5: 0x56291e9c5931 - std::io::Write::write_fmt::h7dbb1c9a3c254aef
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
6: 0x56291e9ca8b5 - std::sys_common::backtrace::_print::h4e8889719c9ddeb8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
7: 0x56291e9ca8b5 - std::sys_common::backtrace::print::h1506fe2cb3022667
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
8: 0x56291e9ca8b5 - std::panicking::default_hook::{{closure}}::hd9d7ce2a8a782440
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
9: 0x56291e9ca5d6 - std::panicking::default_hook::h5b16ec25444b1b5d
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
10: 0x56291e9cae46 - std::panicking::rust_panic_with_hook::hb0138cb6e6fea3e4
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:698:17
11: 0x56291e9cad37 - std::panicking::begin_panic_handler::{{closure}}::h4cb67095557cd1aa
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:588:13
12: 0x56291e9c92f4 - std::sys_common::backtrace::__rust_end_short_backtrace::h2bfcac279dcdc911
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
13: 0x56291e9caa69 - rust_begin_unwind
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
14: 0x56291e8f33e3 - core::panicking::panic_fmt::h1de71520faaa17d3
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
15: 0x56291e8f8f18 - <pretty_assertions_sorted::SortedDebug<T> as core::fmt::Debug>::fmt::h57312b215cce8a2d
at /home/finomnis/.cargo/registry/src/github.com-1ecc6299db9ec823/pretty_assertions_sorted-1.2.0/src/lib.rs:101:17
16: 0x56291e8f8cb6 - <&T as core::fmt::Debug>::fmt::h08992fb97cb26304
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:2135:62
17: 0x56291e9ebb9b - core::fmt::run::h04a2d130287fdf44
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1245:5
18: 0x56291e9ebb9b - core::fmt::write::h21038c1382fe4264
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1213:26
19: 0x56291e9e61b9 - core::fmt::Write::write_fmt::hb01fdc89301b9dd0
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:187:9
20: 0x56291e9e61b9 - alloc::fmt::format::format_inner::h3fdf7b01996f555c
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/fmt.rs:612:9
21: 0x56291e957ce1 - alloc::fmt::format::{{closure}}::h8d5a6d5a9f27ae79
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/fmt.rs:616:34
22: 0x56291e958fea - core::option::Option<T>::map_or_else::h2173b95551bac11e
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/option.rs:1023:21
23: 0x56291e8f81ee - alloc::fmt::format::hec789ac598d607bd
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/fmt.rs:616:5
24: 0x56291e8f90ec - <pretty_assertions::Comparison<TLeft,TRight> as core::fmt::Display>::fmt::hebb40026d1dd72ef
at /home/finomnis/.cargo/registry/src/github.com-1ecc6299db9ec823/pretty_assertions-1.3.0/src/lib.rs:135:26
25: 0x56291e9ebc1c - core::fmt::write::h21038c1382fe4264
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
26: 0x56291e9cabdc - core::fmt::Write::write_fmt::h7dde5490f740f43d
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:187:9
27: 0x56291e9cabdc - std::panicking::begin_panic_handler::PanicPayload::fill::{{closure}}::he65d23c331dfcce3
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:550:22
28: 0x56291e9cabdc - core::option::Option<T>::get_or_insert_with::hb4d636eeeddd23cb
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/option.rs:1544:49
29: 0x56291e9cabdc - std::panicking::begin_panic_handler::PanicPayload::fill::h4e79032a5d9ce017
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:548:13
30: 0x56291e9cabdc - <std::panicking::begin_panic_handler::PanicPayload as core::panic::BoxMeUp>::get::h7f9447447ad87273
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:566:13
31: 0x56291e9cae31 - std::panicking::rust_panic_with_hook::hb0138cb6e6fea3e4
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:697:34
32: 0x56291e9cad37 - std::panicking::begin_panic_handler::{{closure}}::h4cb67095557cd1aa
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:588:13
33: 0x56291e9c92f4 - std::sys_common::backtrace::__rust_end_short_backtrace::h2bfcac279dcdc911
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
34: 0x56291e9caa69 - rust_begin_unwind
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
35: 0x56291e8f33e3 - core::panicking::panic_fmt::h1de71520faaa17d3
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
36: 0x56291e8f3eea - rust_tmp::test::double_panic::h45d788b1dd43b0d6
at /home/finomnis/work/rust-tmp/src/lib.rs:8:9
37: 0x56291e8f8c6a - rust_tmp::test::double_panic::{{closure}}::h2e78776b44f9e8d8
at /home/finomnis/work/rust-tmp/src/lib.rs:7:5
38: 0x56291e8f858e - core::ops::function::FnOnce::call_once::haa7b0260a53ae747
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
39: 0x56291e92e7b3 - core::ops::function::FnOnce::call_once::h0834638dccd7f44f
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
40: 0x56291e92e7b3 - test::__rust_begin_short_backtrace::h236b9d3086614016
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/test/src/lib.rs:572:5
41: 0x56291e92d5ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h836d617c8cafab84
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
42: 0x56291e92d5ba - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h749e4286e2b07713
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panic/unwind_safe.rs:271:9
43: 0x56291e92d5ba - std::panicking::try::do_call::h43a1b83a3cb9edc8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
44: 0x56291e92d5ba - std::panicking::try::h5622fa742e7f1abc
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
45: 0x56291e92d5ba - std::panic::catch_unwind::h99900a1dadf94a68
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
46: 0x56291e92d5ba - test::run_test_in_process::h3893e153ea830832
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/test/src/lib.rs:595:18
47: 0x56291e92d5ba - test::run_test::run_test_inner::{{closure}}::h1a6c1ab1f6c36f74
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/test/src/lib.rs:489:39
48: 0x56291e8f9b2d - test::run_test::run_test_inner::{{closure}}::hb34d5332aa2ee72c
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/test/src/lib.rs:516:37
49: 0x56291e8f9b2d - std::sys_common::backtrace::__rust_begin_short_backtrace::h99ab4c6a3071a36c
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:122:18
50: 0x56291e8ff558 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h27cba0714207d393
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/mod.rs:505:17
51: 0x56291e8ff558 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h9cf84e534f80e48a
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panic/unwind_safe.rs:271:9
52: 0x56291e8ff558 - std::panicking::try::do_call::hcd5ff80e96737b38
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
53: 0x56291e8ff558 - std::panicking::try::h1813b6532a9dacd8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
54: 0x56291e8ff558 - std::panic::catch_unwind::hff2a46cca1d01f0b
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
55: 0x56291e8ff558 - std::thread::Builder::spawn_unchecked_::{{closure}}::h83c4b74ca1b724fc
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/mod.rs:504:30
56: 0x56291e8ff558 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h9e3eb359359c7897
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
57: 0x56291e9cf5f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1680342795a2dc08
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
58: 0x56291e9cf5f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h45204a69827b0e83
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
59: 0x56291e9cf5f3 - std::sys::unix::thread::Thread::new::thread_start::h5d4e11bbda4161c8
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/thread.rs:108:17
60: 0x7f595c40b609 - start_thread
at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
61: 0x7f595c1db133 - clone
at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
62: 0x0 - <unknown>
thread panicked while panicking. aborting.
It seems that the pretty_assertions_sorted crate has a panic! in one of its functions, causing a double panic.
Disclaimer - personal opinion: Such an error is an indication of bad programming style, in my opinion. I'd avoid the crate for now. (time of writing: pretty_assertions_sorted 1.2.0)
Here is the full reproduction of the error:
#[cfg(test)]
mod test {
use pretty_assertions_sorted::{assert_eq_sorted, Comparison, SortedDebug};
use serde_json::json;
#[test]
fn double_panic_highlevel() {
assert_eq_sorted!(json!({"a":0}), json!(null));
}
#[test]
fn double_panic_midlevel1() {
format!(
"{}",
Comparison::new(
&SortedDebug::new(json!({"a":0})),
&SortedDebug::new(json!(null))
)
);
}
#[test]
fn double_panic_midlevel2() {
format!("{:#?}", &SortedDebug::new(json!({"a":0})));
}
#[test]
fn double_panic_lowlevel1() {
darrentsung_debug_parser::parse(&format!("{:?}", json!({"a":0}))).unwrap();
}
#[test]
fn double_panic_lowlevel2() {
darrentsung_debug_parser::parse("Object {\"a\": Number(0)}").unwrap();
}
}

good day i need tips on how to work around this problem

Write a C++ program using switch-case that would ask the user to type a temperature in Fahrenheit then will be converted by the program in Celsius and will display a suitable message according to temperature state below:
Temp < 0 then Freezing weather
Temp 1-10 then Very Cold weather
Temp 11-20 then Cold weather
Temp 21-30 then Normal in Temp
Temp 31-40 then Its Hot
Temp >=40 then Its Very Hot
i can work around the conversion process, but i cannot understand how to implement it using switch case,
switch-case can accept only expression and result of this expression. You can do it in a bit bulky way. But keep in mind that this style is low-readable and actually you'd better use simple if else constructions.
#include <iostream>
using namespace std;
int main()
{
int temperature;
cin >> temperature;
switch(temperature)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
cout << "Very cold";
break;
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
cout << "Cold";
break;
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
cout << "Normal";
break;
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
cout << "Hot";
break;
default:
if(temperature<0)
cout << "Freezing";
if(temperature>=40)
cout << "Very hot";
}
}

Rust smartcore index out of bounds

I'm trying to implement a decision tree using rust smartcore lib.
main:
extern crate csv;
extern crate ndarray;
extern crate ndarray_csv;
use smartcore::linalg::naive::dense_matrix::*;
use smartcore::tree::decision_tree_classifier::*;
use csv::ReaderBuilder;
use ndarray::Array2;
use ndarray_csv::Array2Reader;
fn main() {
let mut reader = ReaderBuilder::new()
.has_headers(true)
.delimiter(b';')
.from_path("./src/result.csv")
.expect("can create reader");
let array: Array2<f64> = reader
.deserialize_array2_dynamic()
.expect("can deserialize array");
let data_set = DenseMatrix::from_array(
array.shape()[0],
array.shape()[1],
&array.as_slice().unwrap()
);
let data = data_set.slice( 0..data_set.shape().0 , 0..3);
let targets = data_set.slice( 0..data_set.shape().0 , 3..6);
let tree = DecisionTreeClassifier::fit(&data, &targets.to_row_vector(), Default::default()).unwrap();
let _y_hat = tree.predict(&data).unwrap(); // use the same data for prediction
}
Cargo.toml:
[package]
name = "RustTest"
version = "0.1.0"
edition = "2021"
[dependencies]
smartcore = "0.2.0"
csv = "1.1.6"
ndarray-csv = "0.5.1"
ndarray = "0.15.4"
I'm getting
thread 'main' panicked at 'index out of bounds: the len is 235200 but the index is 235200', /Users/Ezberci/.cargo/registry/src/github.com-1ecc6299db9ec823/smartcore-0.2.0/src/tree/decision_tree_classifier.rs:359:29 stack backtrace: 0: 0x101fa9e91 - std::backtrace_rs::backtrace::libunwind::trace::h0b624e35bf84187c
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x101fa9e91 - std::backtrace_rs::backtrace::trace_unsynchronized::h435d9bd636904605
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x101fa9e91 - std::sys_common::backtrace::_print_fmt::h3ca407d645e7e73d
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5 3: 0x101fa9e91 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f26ffad025fdbe8
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22 4: 0x101fc399b - core::fmt::write::h0a9937d83d3944c1
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17 5: 0x101fa70e8 - std::io::Write::write_fmt::hfaf2e2e92eda8127
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15 6: 0x101fabe27 - std::sys_common::backtrace::_print::h11335bd900abe1ce
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5 7: 0x101fabe27 - std::sys_common::backtrace::print::hdf5291c87f745042
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9 8: 0x101fabe27 - std::panicking::default_hook::{{closure}}::hc11e9b8d348e68b0
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50 9: 0x101faba35 - std::panicking::default_hook::h1d26ec4d0d63be04
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9 10: 0x101fac4b0 - std::panicking::rust_panic_with_hook::hef4f5e524db188b3
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17 11: 0x101fac1de - std::panicking::begin_panic_handler::{{closure}}::h6e8805ea2351af89
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13 12: 0x101faa307 - std::sys_common::backtrace::__rust_end_short_backtrace::hd383ade987b76f63
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18 13: 0x101fabeca - rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5 14: 0x101fc9d0f - core::panicking::panic_fmt::hb58956db718d5b79
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14 15: 0x101fc9cd6 - core::panicking::panic_bounds_check::hb399dc81a1fa1f74
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5 16: 0x101f77136 - <usize as core::slice::index::SliceIndex<[T]>>::index::ha5785fd1643669bf
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:189:10 17: 0x101f77087 - core::slice::index::<impl core::ops::index::Index<I> for [T]>::index::h0f2c419b17bda497
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:15:9 18: 0x101f19eb8 - <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index::hb9329b8fb73feeb1
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2520:9 19: 0x101f375fb - smartcore::tree::decision_tree_classifier::DecisionTreeClassifier<T>::fit_weak_learner::h733186b4eeecad3a
at /Users/Ezberci/.cargo/registry/src/github.com-1ecc6299db9ec823/smartcore-0.2.0/src/tree/decision_tree_classifier.rs:359:29 20: 0x101f36f24 - smartcore::tree::decision_tree_classifier::DecisionTreeClassifier<T>::fit::h17bbaa15ed674329
at /Users/Ezberci/.cargo/registry/src/github.com-1ecc6299db9ec823/smartcore-0.2.0/src/tree/decision_tree_classifier.rs:326:9 21: 0x101f2e52b - RustTest::main::h7bebf0fe120ff244
at /Users/Ezberci/Desktop/RustTest/src/main.rs:34:16 22: 0x101f339be - core::ops::function::FnOnce::call_once::h88e0f90abf56ec76
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5 23: 0x101f29601 - std::sys_common::backtrace::__rust_begin_short_backtrace::had3be60cba91effe
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:123:18 24: 0x101f23b54 - std::rt::lang_start::{{closure}}::habb4a06572314f48
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:145:18 25: 0x101fa959e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h1d1e9294d7151cb0
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:259:13 26: 0x101fa959e - std::panicking::try::do_call::h315943602cc1e70c
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40 27: 0x101fa959e - std::panicking::try::h5be753f80fffd492
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19 28: 0x101fa959e - std::panic::catch_unwind::h9fdcb02c74b07e26
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14 29: 0x101fa959e - std::rt::lang_start_internal::{{closure}}::h1558447834abc29f
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:48 30: 0x101fa959e - std::panicking::try::do_call::h5721bf6e49d6926d
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40 31: 0x101fa959e - std::panicking::try::hee7cffb35a5e550d
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19 32: 0x101fa959e - std::panic::catch_unwind::hf45e91e6006ab16e
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14 33: 0x101fa959e - std::rt::lang_start_internal::h64086fc6655bfbe8
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:20 34: 0x101f23b2e - std::rt::lang_start::h8ea4706036a83281
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:144:17 35: 0x101f31ef6 - <unknown>
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/cmp.rs:1347:21
Process finished with exit code 101
I have 235201 line in the csv file. I don't have any empty line and even if I change the number of rows the error changes accordingly. How can I fix this error?

Rust `std::time::Instant` "panicked at 'supplied instant is later than self"

I'm trying to get a simple timer set up in rust that returns true at a certain frequency.
#[derive(Clone, Debug)]
pub struct IntervalTimer {
pub period: Duration,
pub delta: Instant,
}
impl IntervalTimer {
pub fn new(period: Duration) -> Self {
let delta = Instant::now();
Self { period, delta }
}
/// Returns true if the interval between calls has exceeded the period
pub fn ready(&mut self) -> bool {
if self.delta.elapsed() < self.period {
false
} else {
self.delta = self.delta + self.period;
true
}
}
}
For some reason, this seems to consistently panic when using std::time::Instant within rayon tasks (running in Legion ECS if that matters).
This was the only other post with information in it that gives the same info but it came down to using an unusual kernel. I'm just using Ubuntu 18.04 with nothing unusual set up.
https://github.com/rust-lang/rust/issues/59673
Additionally, I've tried multiple machines but the same error occurs witht he code.
Is this something to do with using std::time::Instant and rayon?
thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'supplied instant is later than self', src/libstd/time.rs:263:9
stack backtrace:
supplied instant is later than self', src/libstd/time.rs:263:9
0: 0x5574c8e3b9e4 - backtrace::backtrace::libunwind::trace::hc1c4a1d8ad423b97
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: 0x5574c8e3b9e4 - backtrace::backtrace::trace_unsynchronized::h82274781060cb056
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: 0x5574c8e3b9e4 - std::sys_common::backtrace::_print_fmt::h2a45d89b653a4da8
at src/libstd/sys_common/backtrace.rs:78
3: 0x5574c8e3b9e4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h41a0a93ab85e6aa1
at src/libstd/sys_common/backtrace.rs:59
4: 0x5574c8e64b2c - core::fmt::write::hdaea18585065a96d
at src/libcore/fmt/mod.rs:1069
5: 0x5574c8e34743 - std::io::Write::write_fmt::h0cea70c809005252
at src/libstd/io/mod.rs:1504
6: 0x5574c8e3e7a5 - std::sys_common::backtrace::_print::hd95f9978cc145ca4
at src/libstd/sys_common/backtrace.rs:62
7: 0x5574c8e3e7a5 - std::sys_common::backtrace::print::hfb25ca2291be47d0
at src/libstd/sys_common/backtrace.rs:49
8: 0x5574c8e3e7a5 - std::panicking::default_hook::{{closure}}::h44f76cee5dc8591c
at src/libstd/panicking.rs:198
9: 0x5574c8e3e4e2 - std::panicking::default_hook::h198e1a712910f1e6
at src/libstd/panicking.rs:218
10: 0x5574c8e3ee02 - std::panicking::rust_panic_with_hook::hc0b4730bb8013f9d
at src/libstd/panicking.rs:511
11: 0x5574c8e3e9eb - rust_begin_unwind
at src/libstd/panicking.rs:419
12: 0x5574c8e62921 - core::panicking::panic_fmt::h1ac71ad045d55416
at src/libcore/panicking.rs:111
13: 0x5574c8e626b3 - core::option::expect_failed::h7baa1c60813ff0e3
at src/libcore/option.rs:1260
14: 0x5574c8e3b3e5 - core::option::Option<T>::expect::h306e330bd810d3ba
at /rustc/49cae55760da0a43428eba73abcb659bb70cf2e4/src/libcore/option.rs:347
15: 0x5574c8e3b3e5 - std::time::Instant::duration_since::hba1f841dfadd1cd2
at src/libstd/time.rs:263
16: 0x5574c8e3b3e5 - <std::time::Instant as core::ops::arith::Sub>::sub::h73cd3ea7a55658e1
at src/libstd/time.rs:390
17: 0x5574c8e3b3e5 - std::time::Instant::elapsed::h67e85e1d84cb14d0
at src/libstd/time.rs:327
18: 0x5574c8bfe09f - locus_sim_engine::utils::interval_timer::IntervalTimer::ready::h7569661c5fd39089
at src/utils/interval_timer.rs:17
19: 0x5574c8bfe09f - locus_sim_engine::system::laser_scan::single_laser_scan::h671b01a54874470e
at src/system/laser_scan.rs:63
20: 0x5574c8bf074d - locus_sim_engine::system::laser_scan::laser_scan::{{closure}}::h1deba93ec7418c4d
at src/system/laser_scan.rs:50
21: 0x5574c8bf074d - core::ops::function::impls::<impl core::ops::function::Fn<A> for &F>::call::h96b179e6c0dd1ac0
at /home/michael/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:242
22: 0x5574c8bf074d - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut::h4f8d7ff151c5feb5
at /home/michael/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:252
23: 0x5574c8a918f8 - <locus_sim_api::motor_server::MotorServer<T> as tower_service::Service<http::request::Request<B>>>::call::{{closure}}::hf5b46adb51805ebe
at /home/michael/locus_dev/src/locus_sim_engine/target/release/build/locus-sim-api-4d28cb656733f563/out/locus_sim_api.rs:531
24: 0x5574c8a918f8 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9798dbde38a1f607
at /home/michael/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/mod.rs:66
25: 0x5574c8a104ad - <core::pin::Pin<P> as core::future::future::Future>::poll::h6aa9c7207adebc07
at /home/michael/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/future/future.rs:118
26: 0x5574c8a104ad - <F as futures_core::future::TryFuture>::try_poll::h5633e6d6a71350d5
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.5/src/future.rs:83
27: 0x5574c8a104ad - <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll::h20812bb48a44deb6
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/try_future/into_future.rs:31
28: 0x5574c8a104ad - <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll::h7de76b6b06dabc84
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/future/map.rs:67
29: 0x5574c8a10298 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::h87636451ef52bf16
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
30: 0x5574c8a10298 - <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll::hf361a24bd15b64de
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
31: 0x5574c8a10298 - <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll::h3ba6a79df0fece24
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/either.rs:65
32: 0x5574c8a10298 - <F as futures_core::future::TryFuture>::try_poll::h5d9826bce7bec57c
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.5/src/future.rs:83
33: 0x5574c8a10298 - <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll::h8cc4e2435674ca81
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/try_future/into_future.rs:31
34: 0x5574c8a10298 - <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll::h3a97595fa35bf6b4
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/future/map.rs:67
35: 0x5574c8a10645 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::h1f03e91c826fb89f
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
36: 0x5574c8a10645 - <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll::hbb30c6370d1ad4dd
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
37: 0x5574c8a10645 - <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll::h45a493d70ab6cb16
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/either.rs:66
38: 0x5574c8a10645 - <F as futures_core::future::TryFuture>::try_poll::h3218040a42683b8c
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.5/src/future.rs:83
39: 0x5574c8a10645 - <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll::hffacf042cca96add
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/try_future/into_future.rs:31
40: 0x5574c8a10645 - <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll::hd3999158d5641280
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/future/map.rs:67
41: 0x5574c8a0fca0 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::he914f5b3eab7d7ff
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
42: 0x5574c8a0fca0 - <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll::haa236b3c8a953e0b
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
43: 0x5574c8a0fca0 - <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll::h79e46a6c42aa3fc0
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/either.rs:66
44: 0x5574c8a0fca0 - <F as futures_core::future::TryFuture>::try_poll::h11442ab0450f9aba
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-core-0.3.5/src/future.rs:83
45: 0x5574c8a0fca0 - <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll::h4514bbaa544f1a54
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/try_future/into_future.rs:31
46: 0x5574c8a0fca0 - <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll::h3467a48e5d1b449e
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/future/future/map.rs:67
47: 0x5574c8a0f5e5 - <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll::hc132b12a66e846ba
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
48: 0x5574c8a0f5e5 - <futures_util::future::try_future::MapErr<Fut,F> as core::future::future::Future>::poll::hbbbc3932986b69ae
at /home/michael/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/lib.rs:107
Your code is completely correct. You should submit a bug to https://github.com/rust-lang/rust. Windows and ARM Linux already have workarounds for similar issues.
My guess is that the task is jumping around to different cores and their clocks are not in lockstep, thus causing the non-monotonicity.
elapsed() just calculates now() - *self So instead of checking elapsed() > period check if now() > delta + period

Vim PHP short tag syntax highlighting

I'm having trouble getting my VIM to correctly syntax highlight php short tags.
let php_sql_query=1
let php_htmlInStrings=1
let php_noShortTags=0
let php_folding=0
let php_baselib=1
let php_asp_tags=0
let php_parent_error_close=1
let php_parent_error_open=1
"let php_sync_method=10 " Sync only 10 lines backwards
let php_alt_comparisons=1
let php_alt_assignByReference=1
Is all all set in my vimrc file already. I can't find any help on noShortTags but changing from 0 to 1 has no effect.
Output from :scriptnames
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim72/debian.vim
3: /usr/share/vim/vim72/syntax/syntax.vim
4: /usr/share/vim/vim72/syntax/synload.vim
5: /usr/share/vim/vim72/syntax/syncolor.vim
6: /usr/share/vim/vim72/filetype.vim
7: /usr/share/vim/vim72/ftplugin.vim
8: /usr/share/vim/vim72/colors/elflord.vim
9: /etc/vim/toggle.vim
10: /etc/vim/plugin/NERD_tree.vim
11: /home/rwalsh/.vim/plugin/camelcasemotion.vim
12: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
13: /usr/share/vim/vim72/plugin/gzip.vim
14: /usr/share/vim/vim72/plugin/matchparen.vim
15: /usr/share/vim/vim72/plugin/netrwPlugin.vim
16: /usr/share/vim/vim72/plugin/rrhelper.vim
17: /usr/share/vim/vim72/plugin/spellfile.vim
18: /usr/share/vim/vim72/plugin/tarPlugin.vim
19: /usr/share/vim/vim72/plugin/tohtml.vim
20: /usr/share/vim/vim72/plugin/vimballPlugin.vim
21: /usr/share/vim/vim72/plugin/zipPlugin.vim
22: /usr/share/vim/vim72/syntax/php.vim
23: /usr/share/vim/vim72/syntax/html.vim
24: /usr/share/vim/vim72/syntax/javascript.vim
25: /usr/share/vim/vim72/syntax/vb.vim
26: /usr/share/vim/vim72/syntax/css.vim
27: /usr/share/vim/vim72/syntax/sql.vim
28: /usr/share/vim/vim72/syntax/sqloracle.vim
29: /usr/share/vim/vim72/ftplugin/php.vim
30: /usr/share/vim/vim72/ftplugin/html.vim
31: /etc/vim/nerdtree_plugin/exec_menuitem.vim
32: /etc/vim/nerdtree_plugin/fs_menu.vim
33: /home/rwalsh/.vim/autoload/camelcasemotion.vim
I was hoping php (line 22) would take care of it. I have taken a screen shot (below) which shows how it is highlighted with long tags (line 60) and with short tags (line 61, 62, 89-92).
Screenshot
A user over on reddit found that VIM's php sytntax only checks that php_noShortTags exists. Simply commenting it out or removing from my .vimrc file fixed it.

Resources