Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread '<unnamed>' panicked at 'NtWriteFile not available', library\std\src\sys\windows\c.rs:1293:9 #263

Closed
brandonros opened this issue Jun 6, 2022 · 4 comments

Comments

@brandonros
Copy link

brandonros commented Jun 6, 2022

Loading DLL: C:\dpdu-http\dpdu-http-vpi.dll
2022-06-06T17:46:07.926239600-04:00 DEBUG vpi - ctor
thread '<unnamed>' panicked at '`NtWriteFile` not available', library\std\src\sys\windows\c.rs:1293:9
stack backtrace:
   0: 0x694720ea - core::fmt::write
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\core\src\fmt\mod.rs:1196
   1: 0x69452b11 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\io\mod.rs:1654
   2: 0x6945bb5c - std::sys_common::backtrace::_print
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\sys_common\backtrace.rs:48
   3: 0x6945bb5c - std::sys_common::backtrace::print
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\sys_common\backtrace.rs:35
   4: 0x6945bb5c - std::panicking::default_hook::closure$1
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\panicking.rs:295
   5: 0x6945b748 - std::panicking::default_hook
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\panicking.rs:314
   6: 0x6945c247 - std::panicking::rust_panic_with_hook
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\panicking.rs:698
   7: 0x6945c0f6 - std::panicking::begin_panic_handler::closure$0
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\panicking.rs:586
   8: 0x6945a1ef - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\sys_common\backtrace.rs:138
   9: 0x6945bdc2 - std::panicking::begin_panic_handler
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\panicking.rs:584
  10: 0x6947b6df - core::panicking::panic_fmt
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\core\src\panicking.rs:142
  11: 0x6945e31e - std::sys::windows::handle::Handle::synchronous_write
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\sys\windows\handle.rs:309
  12: 0x6945e091 - std::sys::windows::handle::Handle::write
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401/library\std\src\sys\windows\handle.rs:195
  13: 0x6923aa2f - std::io::buffered::bufwriter::BufWriter<std::fs::File>::flush_buf<std::fs::File>
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401\library\std\src\io\buffered\bufwriter.rs:166
  14: 0x6925704d - log4rs::encode::writer::simple::impl$0::flush<std::io::buffered::bufwriter::BufWriter<std::fs::File> >
                       at C:\Users\Brandon\.cargo\registry\src\gh.neting.cc-1285ae84e5963aae\log4rs-1.0.0\src\encode\writer\simple.rs:19
  15: 0x6925649b - alloc::vec::impl$20::into_iter<alloc::boxed::Box<dyn$<log4rs::filter::Filter>,alloc::alloc::Global>,alloc::alloc::Global>
                       at /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401\library\alloc\src\vec\mod.rs:2671
  16: 0x69251427 - log4rs::ConfiguredLogger::log
                       at C:\Users\Brandon\.cargo\registry\src\gh.neting.cc-1285ae84e5963aae\log4rs-1.0.0\src\lib.rs:284
  17: 0x6944384d - log::RecordBuilder::build
                       at C:\Users\Brandon\.cargo\registry\src\gh.neting.cc-1285ae84e5963aae\log-0.4.17\src\lib.rs:1141
  18:   0x19ee80 - <unknown>
  19: 0x68c12885 - vpi::init___rust_ctor___ctor::init___rust_ctor___ctor
                       at C:\Users\Brandon\Desktop\dpdu-http\vpi\vpi.rs:847
  20: 0x7707ac47 - initterm
  21: 0x69479770 - dllmain_crt_process_attach
                       at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:64
  22: 0x694796cf - dllmain_crt_dispatch
                       at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:219
  23: 0x694798f7 - dllmain_dispatch
                       at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:276
  24: 0x694799f0 - _DllMainCRTStartup
                       at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp:334
  25: 0x777f2976 - RtlIpv6AddressToStringA
  26: 0x777cdd22 - RtlActivateActivationContextUnsafeFast
  27: 0x777d1823 - RtlEqualUnicodeString
  28: 0x777d1991 - RtlEqualUnicodeString
  29: 0x777d2235 - RtlIsCriticalSectionLockedByThread
  30: 0x777ce252 - LdrLoadDll
  31: 0x777cde96 - LdrLoadDll
  32: 0x77381526 - LoadLibraryExW
  33: 0x77382042 - LoadLibraryA
  34:   0x4bf79a - <unknown>
  35:   0x41c52c - <unknown>
  36:   0x516193 - <unknown>
  37:   0x515f5d - <unknown>
  38: 0x75dcfa29 - BaseThreadInitThunk
  39: 0x777e7a7e - RtlGetAppContainerNamedObjectPath
  40: 0x777e7a4e - RtlGetAppContainerNamedObjectPath
C:\tmp>rustup update
info: syncing channel updates for 'nightly-i686-pc-windows-msvc'
info: checking for self-updates

   nightly-i686-pc-windows-msvc unchanged - rustc 1.63.0-nightly (fee3a459d 2022-06-05)

info: cleaning up downloads & tmp directories
[dependencies]
log = "0.4.17"
log4rs = { version = "1.0.0", features = ["console_appender", "file_appender", "pattern_encoder"] }
@brandonros
Copy link
Author

not sure what's going on, might be ctor or this library or neither? also opened mmastrac/rust-ctor#219

@ChrisDenton
Copy link

Hi, this is likely caused by the ctor. Rust std currently uses a ctor to load some functions. So if other code also runs in a ctor it's possible that it runs before the std ctor. This would cause it to think the function couldn't be loaded.

This should be fixed in Rust's std to ensure this does not happen. I'll submit a patch to Rust as soon as I'm able.

@brandonros
Copy link
Author

image

No problem. Thanks. If that helps at all, it's as if NtWriteFile is getting dropped by the linker or something?

Is there a way I could make my ctor fire after the Rust std ctor? I've had this code working before. It recently changed when I switched to workspace modules, etc.

@brandonros
Copy link
Author

will continue the issue in ctor since it is a better fit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants