kaist-cp/cs431

List Set different behavior of GUI test and command line invocation

Closed this issue · 9 comments

When I run the stress_sequential test from the GUI on VS code it passes, but when I run the same test via the command line with cargo --test it fails with "failure to exit properly". When I run it again with -- --nocapture, I get the following output:
iteration 1146: insert(231, ())
0x7ff9ca3226b1 - RtlUserThreadStartiteration 1147: lookup(78) (non-existing)

error: test failed, to rerun pass --test list_set

Caused by:
process didn't exit successfully: C:\Users\brian\CS431_KAIST\cs431\homework\target\debug\deps\list_set-e35ac65ca79a412c.exe --nocapture (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

However, I am not sure what this error means or why it works on GUI but no the command line. Any help is appreciated.

Please

  1. Use the proper template.
  2. Use a proper title.
  3. Paste the entire error message/terminal command.

Without this, it's really inefficient for us to debug your code...

To answer your question, I'm not sure why they have a different outcome. Sine the error message from the command line invocation suggests stack corruption, it may be that the GUI test just had good luck.

Also, it seems you are running on a windows. Do you still have the same problem on the provided server?

Hm, I don't think the GUI tests got lucky because I ran them multiple times (~10) and they still passed each time. Also the GUI passes all the tests not just sequential.


other iteration outputs...
iteration 4093: lookup(176) (existing)
iteration 4094: delete(149) (existing)
iteration 4095: insert(178, ())


successes:
    fine_grained::stress_sequential

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finished in 0.01s

If I run the run cargo test without -- --no capture I get the following result:

PS C:\Users\brian\CS431_KAIST\cs431\homework> cargo test --test list_set
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.18s
     Running tests\list_set\main.rs (target\debug\deps\list_set-e35ac65ca79a412c.exe)

running 13 tests
test fine_grained::smoke ... ok
test fine_grained::stress_sequential ... ok
error: test failed, to rerun pass `--test list_set`

Caused by:
  process didn't exit successfully: `C:\Users\brian\CS431_KAIST\cs431\homework\target\debug\deps\list_set-e35ac65ca79a412c.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

When I run it with -- --nocapture it outputs something like this:

PS C:\Users\brian\CS431_KAIST\cs431\homework> cargo test --test list_set -- --nocapture 
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.21s
     Running tests\list_set\main.rs (target\debug\deps\list_set-e35ac65ca79a412c.exe)

running 13 tests
thread 'test fine_grained::smoke ... iteration 1: delete(179) (non-existing)
thread 'thread 'optimistic_fine_grained::iter_invalidate_deletedoptimistic_fine_grained::iter_invalidate_end' panicked at ' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs::7777::99:
:
not yet implementedok

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
optimistic_fine_grained::iter_consistent' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs:77not yet implementediteration 2: delete(45) (non-existing)
iteration 3: insert(95, ())

iteration 4: lookup(53) (non-existing)
:9:
not yet implementedthread '
thread 'thread 'thread 'thread 'thread '<unnamed>optimistic_fine_grained::iter_consistentthread 'thread '<unnamed><unnamed>' panicked at thread '<unnamed>thread '<unnamed>thread '' panicked at ' panicked at ' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs<unnamed>' panicked at <unnamed>' panicked at <unnamed>C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs' panicked at thread 'thread '<unnamed><unnamed>thread 'thread '<unnamed>thread '' panicked at ' panicked at <unnamed>' panicked at <unnamed>C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs' panicked at 
iteration 5: delete(95) (existing)
' panicked at thread '::C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs:C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs::optimistic_fine_grained::iter_invalidate_deletedoptimistic_fine_grained::iter_invalidate_endC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs' panicked at :C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs73:81:<unnamed>77:::thread 'iteration 7: delete(167) (non-existing)
<unnamed>iteration 9: insert(161, ())
iteration 10: lookup(113) (non-existing)
:9' panicked at 77::C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs::77113:9:
not yet implemented
9:
not yet implementediteration 11: lookup(70) (non-existing)
:113C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs:9817381::9:
not yet implemented
' panicked at C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsthread ':optimistic_fine_grained::log_concurrent73' panicked at :C:\Users\brian\CS431_KAIST\cs431\homework\src\test\adt\map.rs9:C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs:9:
336not yet implementedthread '
iteration 12: lookup(161) (existing)
:
:73:
:77:77not yet implemented73:9
73:99<unnamed>:9:
not yet implemented:
9:
not yet implemented:77
:
stack backtrace:
:
:99:
not yet implemented9
' panicked at :
C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rsiteration 13: lookup(11) (non-existing)
:77:not yet implemented
:' panicked at 
9:
:not yet implemented
iteration 14: delete(161) (existing)
9iteration 19: delete(27) (non-existing)
:
iteration 22: lookup(167) (non-existing)
not yet implementedC:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs:
:not yet implemented113
:
:iteration 23: delete(213) (non-existing)

iteration 24: insert(205, ())
iteration 25: delete(205) (existing)
36:
called `Result::unwrap()` on an `Err` value: Any { .. }
99not yet implementediteration 26: delete(112) (non-existing)
:
iteration 28: lookup(218) (non-existing)
not yet implementediteration 30: lookup(222) (non-existing)

iteration 31: lookup(117) (non-existing)
not yet implementednot yet implemented
:
not yet implemented
:


not yet implementednot yet implemented

thread 'iteration 32: delete(0) (non-existing)
optimistic_fine_grained::log_concurrent   0:   iteration 34: lookup(168) (non-existing)
' panicked at  iteration 35: delete(49) (non-existing)
C:\Users\brian\CS431_KAIST\cs431\homework\src\list_set\optimistic_fine_grained.rs :iteration 36: lookup(201) (non-existing)
113iteration 37: insert(17, ())
0xiteration 38: lookup(17) (existing)
:iteration 39: delete(17) (existing)
9iteration 40: insert(4, ())
:
iteration 41: delete(153) (non-existing)
not yet implementediteration 42: delete(167) (non-existing)

7ff7e86a2f4aiteration 43: delete(4) (existing)
 - std::backtrace_rs::backtrace::dbghelp64::trace
                  iteration 44: delete(123) (non-existing)
iteration 47: insert(231, ())
iteration 48: lookup(147) (non-existing)
             at iteration 49: insert(79, ())
/rustc/a165f1f65015b1bd4afd2ec50700aaacf2e0c485/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99
   1: iteration 50: insert(67, ())
    0x7ff7e86a2f4a - std::backtrace_rs::backtrace::trace_unsynchronized
    iteration 51: lookup(9) (non-existing)
 iteration 52: insert(231, ())
 iteration 53: insert(138, ())
                         at /rustc/a165f1f65015b1bd4afd2ec50700aaacf2e0c485/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
 iteration 54: delete(191) (non-existing)
 iteration 55: delete(79) (existing)
 iteration 56: delete(113) (non-existing)
2:     iteration 57: insert(64, ())
0xiteration 58: delete(67) (existing)
iteration 59: delete(246) (non-existing)
7ff7e86a2f4aiteration 60: insert(74, ())
 - std::sys_common::backtrace::_print_fmt
      iteration 61: delete(68) (non-existing)
  iteration 62: insert(218, ())

The full cmd output is pretty long so I didn't paste it.

What happens if you run grade-list_set.sh? If you just run cargo test --test list_set either with/without -- --nocapture, it runs the test not only for fine_grained.rs but also for optimistic_fine_grained.rs. This is different from GUI test (written in tests/list_set/fine_grained.rs) which runs only the test for fine_grained.rs. Since it seems you didn't implement optimistic_fine_grained.rs, I can see lots of error come from "not yet implemented". So please run grade-list_set.sh instead of directly running cargo test on the command line since it runs exactly the tests for fine_grained.rs.

I get the following error when I submit it to the server (which I am assuming runs grade-list_set.sh:

Testing fine_grained stress_sequential with cargo --release, timeout 30s...
    Finished `release` profile [optimized] target(s) in 0.03s
     Running tests/list_set/main.rs (target/release/deps/list_set-e5d2231809c8938e)

running 1 test
test fine_grained::stress_sequential ... error: test failed, to rerun pass `--test list_set`

Caused by:
  process didn't exit successfully: `/app/files/checks/68009719-07d0-4161-b3a4-87a9d6502630/cs431/homework/target/release/deps/list_set-e5d2231809c8938e --exact 'fine_grained::stress_sequential'` (signal: 11, SIGSEGV: invalid memory reference)
Test failed:    cargo test --release --test list_set -- --exact fine_grained::stress_sequential
Score: 0 / 45

Does this mean that it is doing on invalid memory access on the stress_seqeuntial? But since the tests work on my local I am not sure how to debug this. I get a similar error when I run cargo --test on the development server.

Yes you're right. You should fix the problem of invalid memory access. If the same error is reproduced in the development server, then you'd better use the development server to debug. For debugging, I guess https://github.com/kaist-cp/cs431/blob/main/homework/README.md might help.

So debugging on the server, I was able to isolate the error to this line of code.

And the test I am running is just one I made up with:

fn my_test() {
    let set = FineGrainedListSet::new();
    println!("HEY");
    assert!(set.insert(1));
}

Running with:

ubuntu@brian-workspace:~/cs431/homework$ cargo test --test list_set my_test
   Compiling cs431-homework v0.1.0 (/home/ubuntu/cs431/homework)
warning: unused import: `std::iter::zip`
 --> tests/list_set/fine_grained.rs:3:5
  |
3 | use std::iter::zip;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `cs431-homework` (test "list_set") generated 1 warning (run `cargo fix --test "list_set"` to apply 1 suggestion)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 34.15s
     Running tests/list_set/main.rs (target/debug/deps/list_set-3cbed31f7a158bf2)

running 1 test
error: test failed, to rerun pass `--test list_set`

Caused by:
  process didn't exit successfully: `/home/ubuntu/cs431/homework/target/debug/deps/list_set-3cbed31f7a158bf2 my_test` (signal: 11, SIGSEGV: invalid memory reference)
ubuntu@brian-workspace:~/cs431/homework$ cargo test --test list_set my_test
   Compiling cs431-homework v0.1.0 (/home/ubuntu/cs431/homework)
warning: unused import: `std::iter::zip`
 --> tests/list_set/fine_grained.rs:3:5
  |
3 | use std::iter::zip;
  |     ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `cs431-homework` (test "list_set") generated 1 warning (run `cargo fix --test "list_set"` to apply 1 suggestion)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 36.58s
     Running tests/list_set/main.rs (target/debug/deps/list_set-3cbed31f7a158bf2)

running 1 test

Do you know why this block of code would work on my local machine, but break on the server? I am not sure what is wrong with this block of code.

I couldn't find any problem that makes invalid memory access on the provided source code. Probably, the error might come from other places. Don't forget to consider your implementation of drop() since it is also called in your testcase.

fn my_test() {
    let set = FineGrainedListSet::new(); // new() is called
    println!("HEY");
    assert!(set.insert(1)); // insert() is called
    // drop() is implicitly called here
}

Oh yes I think the issue is with the drop function:

In my original implementation, I was holding the guard after dropping the node which would have likely been invalid. However, after changing the code to not use the guard, it is still giving the same error. Is this because we are holding on to the value (node) after dropping the guard( mutex guard)? If so, would the correct implementation be to take ownership of the guard before dropping the node?

First of all, please do not upload your entire code here even if your code is incorrect. Exposing your solution might affect other students' learning experience badly. For now, I removed your code.

Also, I guess you can now find out how to solve the problem by yourself since you already have a small testcase that produces an error and I gave you sufficient tips on debugging. As I believe that you can get valuable experiences while debugging your code (and also debugging technique is indeed an important skill that you should have), I suggest you to think more carefully on your code while spending enough time.