Skip to content

Commit 3b8aa3a

Browse files
committed
debug: add tracing to identify nested runtime panic location
1 parent b53294e commit 3b8aa3a

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

crates/uffs-cli/src/commands.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ async fn load_and_filter_data(
824824
if let Some(drive_letter) = effective_drive {
825825
// Single drive search with proper path resolution
826826
let t_read = std::time::Instant::now();
827+
eprintln!("[DEBUG] search_dataframe: before load_or_build_dataframe_cached drive={drive_letter}");
827828

828829
// Use cached DataFrame path for performance (Windows only)
829830
#[cfg(windows)]
@@ -832,6 +833,8 @@ async fn load_and_filter_data(
832833
.await
833834
.with_context(|| format!("Failed to read MFT for drive {drive_letter}:"))?;
834835

836+
eprintln!("[DEBUG] search_dataframe: after load_or_build_dataframe_cached");
837+
835838
// Non-Windows: read directly (no caching)
836839
#[cfg(not(windows))]
837840
let full_df = {

crates/uffs-mft/src/cache.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,18 @@ pub async fn load_or_build_dataframe_cached(
330330
drive: char,
331331
ttl_seconds: u64,
332332
) -> crate::Result<uffs_polars::DataFrame> {
333+
eprintln!("[DEBUG] load_or_build_dataframe_cached: ENTER drive={drive}");
333334
// Use spawn_blocking to run all MFT reading and polars operations on a
334335
// dedicated blocking thread. This avoids nested tokio runtime issues since
335336
// polars uses tokio internally for some operations.
336-
tokio::task::spawn_blocking(move || load_or_build_dataframe_cached_sync(drive, ttl_seconds))
337-
.await
338-
.map_err(|e| crate::MftError::InvalidInput(format!("Task join error: {e}")))?
337+
let result = tokio::task::spawn_blocking(move || {
338+
eprintln!("[DEBUG] load_or_build_dataframe_cached: INSIDE spawn_blocking drive={drive}");
339+
load_or_build_dataframe_cached_sync(drive, ttl_seconds)
340+
})
341+
.await
342+
.map_err(|e| crate::MftError::InvalidInput(format!("Task join error: {e}")))?;
343+
eprintln!("[DEBUG] load_or_build_dataframe_cached: EXIT drive={drive}");
344+
result
339345
}
340346

341347
/// Synchronous version of `load_or_build_dataframe_cached`.
@@ -351,16 +357,24 @@ fn load_or_build_dataframe_cached_sync(
351357
use crate::reader::MftReader;
352358
use crate::usn::query_usn_journal;
353359

360+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: ENTER drive={drive}");
361+
354362
// Try to load from cache first
355363
if let Some((index, _header)) = load_cached_index(drive, ttl_seconds) {
364+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: cache HIT, calling to_dataframe");
356365
tracing::info!(drive = %drive, records = index.records.len(), "📦 Cache hit - converting to DataFrame");
357-
return index.to_dataframe();
366+
let df = index.to_dataframe();
367+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: to_dataframe done");
368+
return df;
358369
}
359370

360371
// Cache miss - read fresh
372+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: cache MISS, reading MFT fresh");
361373
tracing::info!(drive = %drive, "📖 Cache miss - reading MFT fresh");
362374
let reader = MftReader::open_sync(drive)?;
375+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: reader opened, calling read_all_index_sync");
363376
let index = reader.read_all_index_sync()?;
377+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: read_all_index_sync done, records={}", index.len());
364378

365379
// Save to cache for next time
366380
let handle = VolumeHandle::open(drive)?;
@@ -375,7 +389,10 @@ fn load_or_build_dataframe_cached_sync(
375389
}
376390

377391
// Convert to DataFrame
378-
index.to_dataframe()
392+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: calling to_dataframe");
393+
let df = index.to_dataframe();
394+
eprintln!("[DEBUG] load_or_build_dataframe_cached_sync: to_dataframe done");
395+
df
379396
}
380397

381398
/// Multi-drive cache status for coordinated operations.

crates/uffs-mft/src/reader.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,14 +927,16 @@ impl MftReader {
927927
/// Returns an error if MFT reading fails.
928928
#[cfg(windows)]
929929
pub async fn read_all_index(&self) -> Result<crate::index::MftIndex> {
930+
eprintln!("[DEBUG] read_all_index: ENTER volume={}", self.volume);
930931
// Capture configuration to recreate reader in blocking thread
931932
let volume = self.volume;
932933
let mode = self.mode;
933934
let merge_extensions = self.merge_extensions;
934935
let use_bitmap = self.use_bitmap;
935936
let expand_hardlinks = self.expand_hardlinks;
936937

937-
tokio::task::spawn_blocking(move || {
938+
let result = tokio::task::spawn_blocking(move || {
939+
eprintln!("[DEBUG] read_all_index: INSIDE spawn_blocking volume={volume}");
938940
// Create a new reader in the blocking thread
939941
let handle = crate::platform::VolumeHandle::open(volume)?;
940942
let reader = MftReader {
@@ -945,10 +947,14 @@ impl MftReader {
945947
use_bitmap,
946948
expand_hardlinks,
947949
};
948-
reader.read_mft_index_internal(None::<fn(MftProgress)>)
950+
let idx = reader.read_mft_index_internal(None::<fn(MftProgress)>);
951+
eprintln!("[DEBUG] read_all_index: read_mft_index_internal done");
952+
idx
949953
})
950954
.await
951-
.map_err(|e| MftError::InvalidInput(format!("Task join error: {e}")))?
955+
.map_err(|e| MftError::InvalidInput(format!("Task join error: {e}")))?;
956+
eprintln!("[DEBUG] read_all_index: EXIT volume={volume}");
957+
result
952958
}
953959

954960
/// Read MFT into lean index (non-Windows stub).

0 commit comments

Comments
 (0)