작업자 종료 전 취소 경합을 수정하고 회귀 시험을 추가함
- 작성자
- 호시노 히나타
- 작성 시각
- 커밋
21740313b58aa6b4550bd6385a0fd57bcb8fa2f9- 부모
- fdb38ec
변경된 파일 4개
+81-11| @@ -301,7 +301,7 @@ impl Write for FrameBuffer { | ||
| 301 | 301 | Ok(()) |
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 삭제: struct Frame(Vec<u8>); | |
| 304 | 추가: struct Frame(Vec<u8>, bool); | |
| 305 | 305 | impl Drop for Frame { |
| 306 | 306 | fn drop(&mut self) { |
| 307 | 307 | self.0.fill(0); |
| @@ -468,7 +468,7 @@ impl ui::Connection for ProcessConnection { | ||
| 468 | 468 | self.stop.store(true, Ordering::Release); |
| 469 | 469 | return Err("작업자 요청을 직렬화하지 못했습니다".into()); |
| 470 | 470 | } |
| 471 | 삭제: let bytes = Frame(std::mem::take(&mut *self.buffer.0.borrow_mut())); | |
| 471 | 추가: let bytes = Frame(std::mem::take(&mut *self.buffer.0.borrow_mut()), is_cancel); | |
| 472 | 472 | if self.send.as_ref().unwrap().try_send(bytes).is_err() { |
| 473 | 473 | if is_cancel && self.done.load(Ordering::Acquire) { |
| 474 | 474 | self.next += 1; |
| @@ -523,6 +523,9 @@ fn supervise( | ||
| 523 | 523 | let mut output = child.stdout.take().unwrap(); |
| 524 | 524 | let mut errors = child.stderr.take().unwrap(); |
| 525 | 525 | let mut threads = Vec::new(); |
| 526 | 추가: let cancel_write_failed = Arc::new(AtomicBool::new(false)); | |
| 527 | 추가: let terminal_received = Arc::new(AtomicBool::new(false)); | |
| 528 | 추가: let failed_cancel = cancel_write_failed.clone(); | |
| 526 | 529 | let tx = events.clone(); |
| 527 | 530 | let abort = stop.clone(); |
| 528 | 531 | let finished = done.clone(); |
| @@ -538,7 +541,12 @@ fn supervise( | ||
| 538 | 541 | .and_then(|_| input.flush()) |
| 539 | 542 | .is_err() |
| 540 | 543 | { |
| 541 | 삭제: fault(&tx, &abort, "작업자 요청 파이프 쓰기에 실패했습니다"); | |
| 544 | 추가: if frame.1 { | |
| 545 | 추가: // 취소 쓰기 실패는 응답과 실제 종료 결과를 확인한 뒤 판단함. | |
| 546 | 추가: failed_cancel.store(true, Ordering::Release); | |
| 547 | 추가: } else { | |
| 548 | 추가: fault(&tx, &abort, "작업자 요청 파이프 쓰기에 실패했습니다"); | |
| 549 | 추가: } | |
| 542 | 550 | break; |
| 543 | 551 | } |
| 544 | 552 | } |
| @@ -550,6 +558,7 @@ fn supervise( | ||
| 550 | 558 | ); |
| 551 | 559 | let tx = events.clone(); |
| 552 | 560 | let abort = stop.clone(); |
| 561 | 추가: let received_terminal = terminal_received.clone(); | |
| 553 | 562 | threads.push( |
| 554 | 563 | thread::Builder::new() |
| 555 | 564 | .name("zipelo-worker-output".into()) |
| @@ -566,6 +575,9 @@ fn supervise( | ||
| 566 | 575 | fault(&tx, &abort, "작업자 응답이 요청과 일치하지 않습니다"); |
| 567 | 576 | break false; |
| 568 | 577 | } |
| 578 | 추가: if matches!(event, Ok(ui::Event::Terminal(_))) { | |
| 579 | 추가: received_terminal.store(true, Ordering::Release); | |
| 580 | 추가: } | |
| 569 | 581 | if !notify( |
| 570 | 582 | &tx, |
| 571 | 583 | ui::HostEvent::Frame { |
| @@ -644,6 +656,12 @@ fn supervise( | ||
| 644 | 656 | fault(&events, &stop, "작업자 통신 스레드 회수에 실패했습니다"); |
| 645 | 657 | } |
| 646 | 658 | } |
| 659 | 추가: if cancel_write_failed.load(Ordering::Acquire) | |
| 660 | 추가: && !(terminal_received.load(Ordering::Acquire) | |
| 661 | 추가: && status.as_ref().is_some_and(|status| status.success())) | |
| 662 | 추가: { | |
| 663 | 추가: fault(&events, &stop, "작업자 요청 파이프 쓰기에 실패했습니다"); | |
| 664 | 추가: } | |
| 647 | 665 | if let Some(status) = status { |
| 648 | 666 | // 회수와 모든 파이프 핸들 정리가 끝난 뒤에만 닫기 허용 근거를 전달함. |
| 649 | 667 | notify(&events, ui::HostEvent::CleanupComplete); |
| @@ -48,3 +48,5 @@ fixtures/는 generate.py의 Python 표준 라이브러리로 생성한 작은 | ||
| 48 | 48 | 정상 흐름은 제품 작업자를 사용하고, probe.rs는 통신 실패와 생명주기 시험 전용임. |
| 49 | 49 | 사용자 자료를 읽거나 출력하지 않으며 모든 시험 출력은 이 폴더의 runs/ 안에만 생성함. |
| 50 | 50 | 암호 ZIP, 대용량 성능, OS sandbox, 악성 파일 전체 검증과 Windows 실기는 이 시험의 범위 밖임. |
| 51 | 추가: | |
| 52 | 추가: 취소와 종료 경합 회귀 시험은 실제 작업자에 List를 보낸 뒤 화면 poll 전에 취소하는 흐름을 100회 확인함. 취소 파이프 쓰기가 실패해도 검증된 Terminal과 성공 종료가 있으면 원래 결과를 보존하며, Terminal이 없는 조기 종료는 계속 실패로 처리함. 취소 쓰기 오류 판단을 미루어도 EOF와 child wait 전에는 닫기나 작업 교체를 허용하지 않음. |
| @@ -469,3 +469,52 @@ fn late_cancel_after_child_reap_keeps_the_original_terminal_result() { | ||
| 469 | 469 | } |
| 470 | 470 | assert!(connection.poll().is_none()); |
| 471 | 471 | } |
| 472 | 추가: | |
| 473 | 추가: #[test] | |
| 474 | 추가: fn cancel_racing_child_exit_preserves_completed_result_before_poll() { | |
| 475 | 추가: let archive = Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 476 | 추가: .join("../../tests/rust-app-real-worker/fixtures/sample.zip") | |
| 477 | 추가: .canonicalize() | |
| 478 | 추가: .unwrap(); | |
| 479 | 추가: for iteration in 0..100 { | |
| 480 | 추가: let mut factory = ProcessFactory::new(binary("zipelo-archive-worker")); | |
| 481 | 추가: let mut model = Model::default(); | |
| 482 | 추가: assert!(model.begin( | |
| 483 | 추가: Start::List { | |
| 484 | 추가: archive: archive.clone() | |
| 485 | 추가: }, | |
| 486 | 추가: &mut factory | |
| 487 | 추가: )); | |
| 488 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 489 | 추가: model.cancel(); | |
| 490 | 추가: wait(&mut model); | |
| 491 | 추가: assert!(model.confirmed, "iteration={iteration}: {:?}", model.error); | |
| 492 | 추가: assert_eq!(model.terminal.as_ref().unwrap().outcome, Outcome::Completed); | |
| 493 | 추가: assert!(model.error.is_none()); | |
| 494 | 추가: } | |
| 495 | 추가: } | |
| 496 | 추가: | |
| 497 | 추가: #[test] | |
| 498 | 추가: fn cancel_racing_exit_without_terminal_remains_unconfirmed() { | |
| 499 | 추가: let scratch = Scratch::new(); | |
| 500 | 추가: let probe = scratch.path("early-exit"); | |
| 501 | 추가: fs::copy(binary("zipelo-real-worker-probe"), &probe).unwrap(); | |
| 502 | 추가: let mut factory = ProcessFactory::new(probe); | |
| 503 | 추가: let mut model = Model::default(); | |
| 504 | 추가: assert!(model.begin( | |
| 505 | 추가: Start::List { | |
| 506 | 추가: archive: scratch.path("sample.zip") | |
| 507 | 추가: }, | |
| 508 | 추가: &mut factory | |
| 509 | 추가: )); | |
| 510 | 추가: std::thread::sleep(Duration::from_millis(2)); | |
| 511 | 추가: model.cancel(); | |
| 512 | 추가: model.request_close(); | |
| 513 | 추가: model.confirm_close(); | |
| 514 | 추가: assert_eq!(model.close, Close::Waiting); | |
| 515 | 추가: wait(&mut model); | |
| 516 | 추가: assert!(!model.confirmed); | |
| 517 | 추가: assert!(model.terminal.is_none()); | |
| 518 | 추가: assert!(model.error.is_some()); | |
| 519 | 추가: assert_eq!(model.close, Close::Review); | |
| 520 | 추가: } |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | "source_state": "Tested committed integration source. Only this evidence JSON was updated after the full runner completed; hashes identify the tested code and fixtures.", |
| 7 | 7 | "linux_build_crates": 19, |
| 8 | 8 | "linux_test_targets": 19, |
| 9 | 삭제: "rust_tests_passed": 868, | |
| 9 | 추가: "rust_tests_passed": 870, | |
| 10 | 10 | "new_archive_ui_tests_passed": 22, |
| 11 | 11 | "windows_cross_build_crates": 19, |
| 12 | 12 | "windows_runtime_tested": false, |
| @@ -30,7 +30,7 @@ | ||
| 30 | 30 | }, |
| 31 | 31 | { |
| 32 | 32 | "path": "experiments/rust-ui-memory-app/src/archive_process.rs", |
| 33 | 삭제: "sha256": "4a0f066a17f5f02b7c04588a377545853bcad609416c4daf06398d94667a6aa2" | |
| 33 | 추가: "sha256": "52cebb8d1ec237dfbf56d2bb4449d6fce26dc66c594767ac086a9a6577fe2767" | |
| 34 | 34 | }, |
| 35 | 35 | { |
| 36 | 36 | "path": "experiments/rust-ui-memory-app/src/archive_screen.rs", |
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | }, |
| 63 | 63 | { |
| 64 | 64 | "path": "tests/rust-app-real-worker/README.md", |
| 65 | 삭제: "sha256": "1f71868f8988f98c84b7bee4b764685a90d997d78e6b913bf749206662317823" | |
| 65 | 추가: "sha256": "7902bca8e72fc9599492bfe022b123a60b1ae6cad6fbbd8094bb3c5512268a98" | |
| 66 | 66 | }, |
| 67 | 67 | { |
| 68 | 68 | "path": "tests/rust-app-real-worker/fixtures/sample.tar.gz", |
| @@ -74,7 +74,7 @@ | ||
| 74 | 74 | }, |
| 75 | 75 | { |
| 76 | 76 | "path": "tests/rust-app-real-worker/flows.rs", |
| 77 | 삭제: "sha256": "1b38693802cacc8717189662469aaf0effbd13e21c33d69d6dc1e3d5882e9dd4" | |
| 77 | 추가: "sha256": "d2510f60db64cc373a8affd4b7102d16e3733f82e224905e18b7c5633134e8ff" | |
| 78 | 78 | }, |
| 79 | 79 | { |
| 80 | 80 | "path": "tests/rust-app-real-worker/generate.py", |
| @@ -108,11 +108,12 @@ | ||
| 108 | 108 | "Start 전송 실패 시 양쪽 EOF/child wait까지 연결 보존과 닫기/교체 차단", |
| 109 | 109 | "오류 후 명시적 정리는 child wait 전에 닫기를 허용하지 않음", |
| 110 | 110 | "정상 정리 신호는 EOF를 대신하지 않음", |
| 111 | 삭제: "정상 종료 뒤 채널 닫힘과 늦은 취소가 최종 결과를 오류로 바꾸지 않음" | |
| 111 | 추가: "정상 종료 뒤 채널 닫힘과 늦은 취소가 최종 결과를 오류로 바꾸지 않음", | |
| 112 | 추가: "child 회수 전 늦은 취소의 실제 작업자 경합 100회와 Terminal 없는 종료의 실패 유지" | |
| 112 | 113 | ], |
| 113 | 삭제: "before_review_fix": "Earlier PR62 fixes reproduced 3 failures before repair. Integration tests additionally reproduced normal channel shutdown and late-cancel races before repair.", | |
| 114 | 추가: "before_review_fix": "Earlier PR62 fixes reproduced 3 failures before repair. Integration tests additionally reproduced normal channel shutdown and late-cancel races before repair. PR68 review race reproduced with the new test before repair; all 100 iterations passed after repair.", | |
| 114 | 115 | "approved_ui_head": "423a7c80c9d7182e07d29adee03a97d09a19b11f", |
| 115 | 삭제: "tested_local_head": "bc5d01cd282d92c977174c3bbf61072c761f3a34", | |
| 116 | 삭제: "real_worker_tests_passed": 8, | |
| 116 | 추가: "tested_local_head": "32fd1b97ad616c4526deb4d91fed9156be1b026b", | |
| 117 | 추가: "real_worker_tests_passed": 10, | |
| 117 | 118 | "runner_tests_passed": 8 |
| 118 | 119 | } |