Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(error-tracking): cap symbol set decompression in cymbal (#130029)

James Gill911bf2d3bcbe
diff --git a/rust/common/symbol_data/src/error.rs b/rust/common/symbol_data/src/error.rs
index 657a42543305..4a75508a092d 100644
--- a/rust/common/symbol_data/src/error.rs
+++ b/rust/common/symbol_data/src/error.rs
@@ -23,6 +23,8 @@ pub enum Error {
CompressionError(String),
#[error("Unknown compression type: {0}")]
UnknownCompression(u8),
+ #[error("Decompressed data exceeds the {0} byte limit")]
+ DecompressedTooLarge(u64),
}
impl From<FromUtf8Error> for Error {
diff --git a/rust/common/symbol_data/src/lib.rs b/rust/common/symbol_data/src/lib.rs
index 2a1acf1cbd04..9642aedace71 100644
--- a/rust/common/symbol_data/src/lib.rs
+++ b/rust/common/symbol_data/src/lib.rs
@@ -10,6 +10,7 @@ pub use error::Error as SymbolDataError;
pub use symbol_data::known_decompressed_size as symbol_data_known_decompressed_size;
pub use symbol_data::read_as as read_symbol_data;
pub use symbol_data::read_as_with_byte_count as read_symbol_data_with_byte_count;
+pub use symbol_data::read_as_with_byte_count_limited as read_symbol_data_with_byte_count_limited;
pub use symbol_data::write as write_symbol_data;
pub use symbol_data::write_uncompressed as write_symbol_data_uncompressed;
diff --git a/rust/common/symbol_data/src/symbol_data.rs b/rust/common/symbol_data/src/symbol_data.rs
index 1e0a0e24e10e..9ae2a24bcb2c 100644
--- a/rust/common/symbol_data/src/symbol_data.rs
+++ b/rust/common/symbol_data/src/symbol_data.rs
@@ -141,6 +141,20 @@ fn known_zstd_decompressed_size(mut data: &[u8]) -> Result<Option<usize>, Error>
/// This is useful for cache memory accounting when the container uses compression,
/// since the compressed size can be much smaller than the actual data in memory.
pub fn read_as_with_byte_count<T>(data: &[u8]) -> Result<(T, usize), Error>
+where
+ T: SymbolData,
+{
+ read_as_with_byte_count_limited(data, usize::MAX)
+}
+
+/// Like `read_as_with_byte_count`, but fails with `Error::DecompressedTooLarge` instead of
+/// producing a payload larger than `max_bytes`. Use it for data from an untrusted source: a
+/// small zstd frame can decompress to many gigabytes, and the frame header that declares the
+/// size is written by the uploader.
+pub fn read_as_with_byte_count_limited<T>(
+ data: &[u8],
+ max_bytes: usize,
+) -> Result<(T, usize), Error>
where
T: SymbolData,
{
@@ -150,9 +164,9 @@ where
V1_VERSION => {
assert_at_least_as_long_as(v1_header_len(), data.len())?;
assert_data_type_impl(data, T::data_type())?;
- let payload = data[v1_header_len()..].to_vec();
- let byte_count = payload.len();
- T::from_bytes(payload).map(|v| (v, byte_count))
+ let payload = &data[v1_header_len()..];
+ assert_within_limit(payload.len(), max_bytes)?;
+ T::from_bytes(payload.to_vec()).map(|v| (v, payload.len()))
}
VERSION => {
assert_at_least_as_long_as(v2_header_len(), data.len())?;
@@ -160,14 +174,27 @@ where
let compression = Compression::try_from(data[v2_header_len() - 1])?;
let payload = &data[v2_header_len()..];
let decompressed = match compression {
- Compression::None => payload.to_vec(),
+ Compression::None => {
+ assert_within_limit(payload.len(), max_bytes)?;
+ payload.to_vec()
+ }
Compression::Zstd => {
- let mut decoder = zstd::Decoder::new(Cursor::new(payload))
+ // A declared size is safe to reject on but not to trust: zstd fails a frame
+ // whose content does not match its declared size, and a frame can declare
+ // no size at all, so the read below keeps its own cap.
+ if let Ok(Some(declared)) = known_zstd_decompressed_size(payload) {
+ assert_within_limit(declared, max_bytes)?;
+ }
+ let decoder = zstd::Decoder::new(Cursor::new(payload))
.map_err(|e| Error::CompressionError(e.to_string()))?;
let mut out = Vec::new();
+ // One byte past the limit is enough to tell an oversized payload from one
+ // that is exactly at the limit.
decoder
+ .take((max_bytes as u64).saturating_add(1))
.read_to_end(&mut out)
.map_err(|e| Error::CompressionError(e.to_string()))?;
+ assert_within_limit(out.len(), max_bytes)?;
out
}
};
@@ -178,6 +205,13 @@ where
}
}
+fn assert_within_limit(len: usize, max_bytes: usize) -> Result<(), Error> {
+ if len > max_bytes {
+ return Err(Error::DecompressedTooLarge(max_bytes as u64));
+ }
+ Ok(())
+}
+
fn read_version(buffer: &[u8]) -> Result<u32, Error> {
assert_at_least_as_long_as(MAGIC.len() + 4, buffer.len())?;
assert_has_magic(buffer)?;
diff --git a/rust/common/symbol_data/tests/test.rs b/rust/common/symbol_data/tests/test.rs
index a9db99db45ab..fb55a4a91970 100644
--- a/rust/common/symbol_data/tests/test.rs
+++ b/rust/common/symbol_data/tests/test.rs
@@ -1,9 +1,9 @@
use std::io::Write;
use posthog_symbol_data::{
- read_symbol_data, symbol_data_known_decompressed_size, write_symbol_data,
- write_symbol_data_uncompressed, AppleDsym, ElfDebugInfo, HermesMap, ProguardMapping,
- SourceAndMap,
+ read_symbol_data, read_symbol_data_with_byte_count_limited,
+ symbol_data_known_decompressed_size, write_symbol_data, write_symbol_data_uncompressed,
+ AppleDsym, ElfDebugInfo, HermesMap, ProguardMapping, SourceAndMap, SymbolDataError,
};
const MAGIC_LEN: usize = b"posthog_error_tracking".len();
@@ -81,6 +81,42 @@ fn test_v2_compressed_without_content_size() {
assert_eq!(symbol_data_known_decompressed_size(&bytes).unwrap(), None);
}
+#[test]
+fn test_limited_read_stops_at_the_limit() {
+ let limit = 1024;
+ let at_limit = ElfDebugInfo {
+ data: vec![0; limit],
+ };
+ let bytes = write_symbol_data(at_limit.clone()).unwrap();
+ assert_eq!(
+ read_symbol_data_with_byte_count_limited::<ElfDebugInfo>(&bytes, limit).unwrap(),
+ (at_limit, limit)
+ );
+
+ let over_limit = write_symbol_data(ElfDebugInfo {
+ data: vec![0; limit + 1],
+ })
+ .unwrap();
+ let uncompressed_over_limit = write_symbol_data_uncompressed(ElfDebugInfo {
+ data: vec![0; limit + 1],
+ })
+ .unwrap();
+
+ // A frame that declares no content size decodes until the frame ends.
+ let mut encoder = zstd::Encoder::new(Vec::new(), 3).unwrap();
+ encoder.write_all(&vec![0; 64 * limit]).unwrap();
+ let mut undeclared_size = write_symbol_data(ElfDebugInfo { data: Vec::new() }).unwrap();
+ undeclared_size.truncate(COMPRESSION_OFFSET + 1);
+ undeclared_size.extend(encoder.finish().unwrap());
+
+ for bytes in [over_limit, uncompressed_over_limit, undeclared_size] {
+ assert_eq!(
+ read_symbol_data_with_byte_count_limited::<ElfDebugInfo>(&bytes, limit).unwrap_err(),
+ SymbolDataError::DecompressedTooLarge(limit as u64)
+ );
+ }
+}
+
#[test]
fn test_v2_uncompressed_header() {
let input = SourceAndMap {
diff --git a/rust/cymbal/src/core/config.rs b/rust/cymbal/src/core/config.rs
index 9979ea8f251b..67b1335e0477 100644
--- a/rust/cymbal/src/core/config.rs
+++ b/rust/cymbal/src/core/config.rs
@@ -122,6 +122,18 @@ pub struct ResolverConfig {
#[envconfig(default = "8")]
pub symbol_set_parse_memory_multiplier: NonZeroUsize,
+ // A small compressed symbol set can decompress to many gigabytes, and the size its container
+ // declares is written by the uploader. A parse fails instead of decompressing a container
+ // payload past this many bytes.
+ #[envconfig(default = "536870912")] // 512 MiB
+ pub symbol_set_max_decompressed_bytes: NonZeroUsize,
+
+ // Native and Apple symbol sets are a ZIP of deflated entries inside the container, so they
+ // expand a second time. A parse reads at most this many bytes out of the ZIP, summed over
+ // every entry it reads.
+ #[envconfig(default = "1610612736")] // 1.5 GiB
+ pub symbol_set_max_extracted_bytes: NonZeroUsize,
+
// Shared secret authenticating the cymbal <-> cymbal-resolution gRPC seam.
#[envconfig(default = "")]
pub internal_api_secret: String,
diff --git a/rust/cymbal/src/core/metric_consts.rs b/rust/cymbal/src/core/metric_consts.rs
index cc42b9582df0..5a99cdc36f93 100644
--- a/rust/cymbal/src/core/metric_consts.rs
+++ b/rust/cymbal/src/core/metric_consts.rs
@@ -57,6 +57,10 @@ pub const SYMBOL_SET_DECOMPRESSED_BYTES: &str = "cymbal_symbol_set_decompressed_
// Time a large symbol set parse waits for a `ParseLimiter` permit, in milliseconds.
pub const SYMBOL_SET_LARGE_PARSE_WAIT_MS: &str = "cymbal_symbol_set_large_parse_wait_ms";
pub const SYMBOL_SET_PARSE_INPUT_BYTES: &str = "cymbal_symbol_set_parse_input_bytes";
+// Symbol set parses that failed on a size limit. Labelled by `kind`, and by `limit`:
+// `container` for `SYMBOL_SET_MAX_DECOMPRESSED_BYTES`, `extracted` for
+// `SYMBOL_SET_MAX_EXTRACTED_BYTES`.
+pub const SYMBOL_SET_SIZE_LIMIT_EXCEEDED: &str = "cymbal_symbol_set_size_limit_exceeded";
// Histogram buckets for the byte-shaped metrics above. The default
// `common_metrics` buckets are tuned for milliseconds of latency and saturate
diff --git a/rust/cymbal/src/core/resolver.rs b/rust/cymbal/src/core/resolver.rs
index 283fec219adb..b466f07ebcf9 100644
--- a/rust/cymbal/src/core/resolver.rs
+++ b/rust/cymbal/src/core/resolver.rs
@@ -92,7 +92,7 @@ pub fn build_catalog(
let smp_atmostonce = concurrency::AtMostOne::new(smp_caching);
let hmp_chunk = ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(config),
s3_client.clone(),
posthog_pool.clone(),
config.object_storage_bucket.clone(),
@@ -104,7 +104,7 @@ pub fn build_catalog(
let hmp_atmostonce = concurrency::AtMostOne::new(hmp_caching);
let pgp_chunk = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(config),
s3_client.clone(),
posthog_pool.clone(),
config.object_storage_bucket.clone(),
@@ -114,7 +114,7 @@ pub fn build_catalog(
let pgp_atmostonce = concurrency::AtMostOne::new(pgp_caching);
let apple_chunk = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(config),
s3_client.clone(),
posthog_pool.clone(),
config.object_storage_bucket.clone(),
@@ -124,7 +124,7 @@ pub fn build_catalog(
let apple_atmostonce = concurrency::AtMostOne::new(apple_caching);
let native_chunk = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(config),
s3_client.clone(),
posthog_pool.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/core/symbolication/symbol/local.rs b/rust/cymbal/src/core/symbolication/symbol/local.rs
index b79fa12c5264..ec900cf1c211 100644
--- a/rust/cymbal/src/core/symbolication/symbol/local.rs
+++ b/rust/cymbal/src/core/symbolication/symbol/local.rs
@@ -476,28 +476,28 @@ mod test {
);
let hmp = ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(&config),
client.clone(),
pool.clone(),
config.object_storage_bucket.clone(),
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
pool.clone(),
config.object_storage_bucket.clone(),
);
let apple = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
pool.clone(),
config.object_storage_bucket.clone(),
);
let native = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
pool.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/apple.rs b/rust/cymbal/src/core/symbolication/symbol_store/apple.rs
index 0de740b07bc9..67bacb3c9929 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/apple.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/apple.rs
@@ -3,15 +3,27 @@ use std::fmt::Display;
use async_trait::async_trait;
use bytes::Bytes;
-use posthog_symbol_data::{read_symbol_data_with_byte_count, AppleDsym};
+use posthog_symbol_data::{read_symbol_data_with_byte_count_limited, AppleDsym};
use crate::{
+ core::config::ResolverConfig,
error::{AppleError, ResolveError, UnhandledError},
- metric_consts::SYMBOL_SET_DECOMPRESSED_BYTES,
symbolication::symbol_store::{native::ParsedNativeSymbols, Fetcher, ParsePermit, Parser},
};
-pub struct AppleProvider {}
+pub struct AppleProvider {
+ max_decompressed_bytes: usize,
+ max_extracted_bytes: usize,
+}
+
+impl AppleProvider {
+ pub fn new(config: &ResolverConfig) -> Self {
+ Self {
+ max_decompressed_bytes: config.symbol_set_max_decompressed_bytes.get(),
+ max_extracted_bytes: config.symbol_set_max_extracted_bytes.get(),
+ }
+ }
+}
#[derive(Debug, Clone)]
pub enum AppleRef {}
@@ -41,24 +53,21 @@ impl Parser for AppleProvider {
// dSYM parsing is the heaviest CPU work in the system: zstd decompress, ZIP
// expansion, DWARF parse, and symcache conversion. Always offload from the tokio
// runtime.
+ let max_decompressed_bytes = self.max_decompressed_bytes;
+ let max_extracted_bytes = self.max_extracted_bytes;
tokio::task::spawn_blocking(move || -> Result<ParsedNativeSymbols, ResolveError> {
let _permit = permit;
// Try to unwrap symbol_data container first (new format),
// fall back to raw ZIP for backward compatibility with existing uploads.
// TODO(2026-09-24): Remove raw ZIP fallback once all old uploads have expired.
- let (zip_data, decompressed_bytes) =
- match read_symbol_data_with_byte_count::<AppleDsym>(&source) {
- Ok((dsym, bytes)) => (dsym.data, bytes),
- Err(_) => {
- let len = source.len();
- (source.to_vec(), len)
- }
- };
- metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => "apple")
- .record(decompressed_bytes as f64);
+ let container = read_symbol_data_with_byte_count_limited::<AppleDsym>(
+ &source,
+ max_decompressed_bytes,
+ )
+ .map(|(dsym, bytes)| (dsym.data, bytes));
// Map shared native parse errors onto AppleError so stored failure
// reasons for apple symbol sets keep their existing shape.
- ParsedNativeSymbols::from_zip_data(zip_data, decompressed_bytes)
+ ParsedNativeSymbols::from_container(container, &source, max_extracted_bytes, "apple")
.map_err(|e| AppleError::from(e).into())
})
.await
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/chunk_id.rs b/rust/cymbal/src/core/symbolication/symbol_store/chunk_id.rs
index b6936a99c089..644a1ccff296 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/chunk_id.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/chunk_id.rs
@@ -501,28 +501,28 @@ mod test {
);
let hermes_map_fetcher = ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let apple = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let native = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/hermesmap.rs b/rust/cymbal/src/core/symbolication/symbol_store/hermesmap.rs
index 2ed656f4a4e7..8fc605f7cf98 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/hermesmap.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/hermesmap.rs
@@ -1,13 +1,16 @@
use async_trait::async_trait;
use bytes::Bytes;
-use posthog_symbol_data::{read_symbol_data_with_byte_count, HermesMap};
+use posthog_symbol_data::{read_symbol_data_with_byte_count_limited, HermesMap};
use serde::Deserialize;
use crate::{
+ core::config::ResolverConfig,
error::{HermesError, ResolveError, UnhandledError},
langs::hermes::HermesRef,
metric_consts::SYMBOL_SET_DECOMPRESSED_BYTES,
- symbolication::symbol_store::{caching::Countable, Fetcher, ParsePermit, Parser},
+ symbolication::symbol_store::{
+ caching::Countable, record_size_limit_exceeded, Fetcher, ParsePermit, Parser,
+ },
};
pub struct ParsedHermesMap {
@@ -57,7 +60,17 @@ impl Countable for ParsedHermesMap {
}
}
-pub struct HermesMapProvider {}
+pub struct HermesMapProvider {
+ max_decompressed_bytes: usize,
+}
+
+impl HermesMapProvider {
+ pub fn new(config: &ResolverConfig) -> Self {
+ Self {
+ max_decompressed_bytes: config.symbol_set_max_decompressed_bytes.get(),
+ }
+ }
+}
#[async_trait]
impl Fetcher for HermesMapProvider {
@@ -83,10 +96,13 @@ impl Parser for HermesMapProvider {
) -> Result<ParsedHermesMap, Self::Err> {
// zstd decompress + Hermes sourcemap parse are both CPU-bound; offload from the
// tokio runtime so a large bundle doesn't block other in-flight requests.
+ let max_decompressed_bytes = self.max_decompressed_bytes;
tokio::task::spawn_blocking(move || -> Result<ParsedHermesMap, ResolveError> {
let _permit = permit;
let (map, decompressed_bytes): (HermesMap, usize) =
- read_symbol_data_with_byte_count(&source).map_err(HermesError::DataError)?;
+ read_symbol_data_with_byte_count_limited(&source, max_decompressed_bytes)
+ .inspect_err(|e| record_size_limit_exceeded(e, "hermes", "container"))
+ .map_err(HermesError::DataError)?;
metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => "hermes")
.record(decompressed_bytes as f64);
Ok(ParsedHermesMap::parse(map, decompressed_bytes)?)
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/mod.rs b/rust/cymbal/src/core/symbolication/symbol_store/mod.rs
index 0d518caaa617..665a5c6df35e 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/mod.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/mod.rs
@@ -3,6 +3,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use chunk_id::OrChunkId;
+use posthog_symbol_data::SymbolDataError;
use reqwest::Url;
use sourcemap::OwnedSourceMapCache;
use tokio::sync::OwnedSemaphorePermit;
@@ -10,6 +11,7 @@ use tokio::sync::OwnedSemaphorePermit;
use crate::{
error::ResolveError,
langs::hermes::HermesRef,
+ metric_consts::SYMBOL_SET_SIZE_LIMIT_EXCEEDED,
symbolication::symbol_store::{
apple::AppleRef,
hermesmap::ParsedHermesMap,
@@ -67,6 +69,19 @@ impl ParsePermit {
}
}
+// The size limits are set from production sizes, so a count here can be a real upload that
+// outgrew them rather than an attack.
+pub(crate) fn record_size_limit_exceeded(
+ error: &SymbolDataError,
+ kind: &'static str,
+ limit: &'static str,
+) {
+ if matches!(error, SymbolDataError::DecompressedTooLarge(_)) {
+ metrics::counter!(SYMBOL_SET_SIZE_LIMIT_EXCEEDED, "kind" => kind, "limit" => limit)
+ .increment(1);
+ }
+}
+
#[async_trait]
pub trait Parser: Send + Sync + 'static {
type Source;
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/native.rs b/rust/cymbal/src/core/symbolication/symbol_store/native.rs
index 48391f934fcf..a7ee691dd91f 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/native.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/native.rs
@@ -10,12 +10,17 @@ use symbolic::demangle::{Demangle, DemangleOptions};
use symbolic::symcache::{SymCache, SymCacheConverter};
use zip::ZipArchive;
-use posthog_symbol_data::{read_symbol_data_with_byte_count, AppleDsym, ElfDebugInfo};
+use posthog_symbol_data::{
+ read_symbol_data_with_byte_count_limited, AppleDsym, ElfDebugInfo, SymbolDataError,
+};
use crate::{
+ core::config::ResolverConfig,
error::{NativeError, ResolveError, UnhandledError},
metric_consts::SYMBOL_SET_DECOMPRESSED_BYTES,
- symbolication::symbol_store::{caching::Countable, Fetcher, ParsePermit, Parser},
+ symbolication::symbol_store::{
+ caching::Countable, record_size_limit_exceeded, Fetcher, ParsePermit, Parser,
+ },
};
/// Manifest format for source files bundled in the symbol ZIP under `__source/`
@@ -40,26 +45,110 @@ pub struct ParsedNativeSymbols {
}
impl Countable for ParsedNativeSymbols {
+ // Bundled sources are inflated out of the ZIP, so the parsed set can hold more memory than
+ // the container it was parsed from.
fn byte_count(&self) -> usize {
+ let sources: usize = self
+ .sources
+ .iter()
+ .flatten()
+ .map(|(path, content)| path.len() + content.len())
+ .sum();
self.decompressed_bytes
+ .max(self.symcache_data.len() + sources)
+ }
+}
+
+// Caps the total bytes read out of one symbol ZIP. The zip crate inflates an entry until its
+// compressed data ends and does not stop at the uncompressed size in the entry header, so
+// each read is cut off at the remaining budget instead.
+struct ExtractionBudget {
+ max_bytes: usize,
+ remaining: usize,
+}
+
+impl ExtractionBudget {
+ fn new(max_bytes: usize) -> Self {
+ Self {
+ max_bytes,
+ remaining: max_bytes,
+ }
+ }
+
+ // Fails with `NativeError::DataError` when the entry does not fit in the remaining budget,
+ // and with `NativeError::ParseError` when the entry cannot be read. A read that fails, for
+ // example on a CRC mismatch at the end of the entry, still inflated its bytes, so they are
+ // charged before the error is returned.
+ fn read(&mut self, entry: impl Read) -> Result<Vec<u8>, NativeError> {
+ let mut data = Vec::new();
+ let result = entry
+ .take((self.remaining as u64).saturating_add(1))
+ .read_to_end(&mut data);
+ if data.len() > self.remaining {
+ return Err(SymbolDataError::DecompressedTooLarge(self.max_bytes as u64).into());
+ }
+ self.remaining -= data.len();
+ result.map_err(|e| NativeError::ParseError(e.to_string()))?;
+ Ok(data)
+ }
+
+ // Like `read`, but gives `None` for an entry that cannot be read, so the caller can skip it.
+ fn read_optional(&mut self, entry: impl Read) -> Result<Option<Vec<u8>>, NativeError> {
+ match self.read(entry) {
+ Ok(data) => Ok(Some(data)),
+ Err(e @ NativeError::DataError(_)) => Err(e),
+ Err(_) => Ok(None),
+ }
}
}
impl ParsedNativeSymbols {
+ /// Parses the result of a symbol_data container read. `kind` labels the metrics.
+ pub fn from_container(
+ container: Result<(Vec<u8>, usize), SymbolDataError>,
+ source: &[u8],
+ max_extracted_bytes: usize,
+ kind: &'static str,
+ ) -> Result<Self, NativeError> {
+ let (zip_data, decompressed_bytes) = match container {
+ Ok(container) => container,
+ Err(e @ SymbolDataError::DecompressedTooLarge(_)) => {
+ record_size_limit_exceeded(&e, kind, "container");
+ return Err(e.into());
+ }
+ // Raw ZIP fallback for uploads from before the symbol_data container was introduced.
+ // TODO(2026-09-24): Remove raw ZIP fallback once all old uploads have expired.
+ Err(_) => (source.to_vec(), source.len()),
+ };
+ metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => kind)
+ .record(decompressed_bytes as f64);
+ Self::from_zip_data(zip_data, decompressed_bytes, max_extracted_bytes).inspect_err(|e| {
+ if let NativeError::DataError(e) = e {
+ record_size_limit_exceeded(e, kind, "extracted");
+ }
+ })
+ }
+
pub fn from_zip_data(
zip_data: Vec<u8>,
decompressed_bytes: usize,
+ max_extracted_bytes: usize,
) -> Result<Self, NativeError> {
let cursor = Cursor::new(zip_data);
let mut archive =
ZipArchive::new(cursor).map_err(|e| NativeError::ParseError(e.to_string()))?;
+ let mut budget = ExtractionBudget::new(max_extracted_bytes);
- let dwarf_data = Self::extract_dwarf_from_zip(&mut archive)?;
+ let dwarf_data = Self::extract_dwarf_from_zip(&mut archive, &mut budget)?;
let symcache_data = Self::convert_to_symcache(&dwarf_data)?;
// Try to load source files from the bundle (graceful — old bundles without source still work)
- let sources = Self::extract_sources_from_zip(&mut archive);
+ let sources =
+ Self::extract_sources_from_zip(&mut archive, &mut budget).unwrap_or_else(|e| {
+ tracing::warn!("Dropping bundled sources from native symbol set: {e}");
+ None
+ });
Ok(Self {
symcache_data,
@@ -69,33 +158,40 @@ impl ParsedNativeSymbols {
}
/// Extract source files from a symbol ZIP that contains a `__source/manifest.json`.
- /// Returns None if no source manifest is found (backward compatible).
+ /// Returns None if no source manifest is found (backward compatible). Fails only when the
+ /// sources exceed the extraction budget; an unreadable entry is skipped.
fn extract_sources_from_zip(
archive: &mut ZipArchive<Cursor<Vec<u8>>>,
- ) -> Option<HashMap<String, String>> {
+ budget: &mut ExtractionBudget,
+ ) -> Result<Option<HashMap<String, String>>, NativeError> {
// Read and parse manifest
- let manifest: SourceManifest = {
- let mut manifest_file = archive.by_name("__source/manifest.json").ok()?;
- let mut manifest_data = Vec::new();
- manifest_file.read_to_end(&mut manifest_data).ok()?;
- serde_json::from_slice(&manifest_data).ok()?
+ let Ok(manifest_file) = archive.by_name("__source/manifest.json") else {
+ return Ok(None);
+ };
+ let Some(manifest_data) = budget.read_optional(manifest_file)? else {
+ return Ok(None);
+ };
+ let Ok(manifest) = serde_json::from_slice::<SourceManifest>(&manifest_data) else {
+ return Ok(None);
};
let mut sources = HashMap::new();
+ // Several manifest keys can name the same entry, and each one reads it again, so every
+ // read is charged to the budget.
for (dwarf_path, zip_path) in &manifest.files {
- if let Ok(mut file) = archive.by_name(zip_path) {
- let mut content = String::new();
- if file.read_to_string(&mut content).is_ok() {
- sources.insert(dwarf_path.clone(), content);
- }
+ let Ok(file) = archive.by_name(zip_path) else {
+ continue;
+ };
+ if let Some(Ok(content)) = budget.read_optional(file)?.map(String::from_utf8) {
+ sources.insert(dwarf_path.clone(), content);
}
}
if sources.is_empty() {
- None
+ Ok(None)
} else {
- Some(sources)
+ Ok(Some(sources))
}
}
@@ -148,29 +244,24 @@ impl ParsedNativeSymbols {
fn extract_dwarf_from_zip(
archive: &mut ZipArchive<Cursor<Vec<u8>>>,
+ budget: &mut ExtractionBudget,
) -> Result<Vec<u8>, NativeError> {
// New format: single DWARF binary stored as "dwarf" at root level
- if let Ok(mut file) = archive.by_name("dwarf") {
- let mut data = Vec::new();
- file.read_to_end(&mut data)
- .map_err(|e| NativeError::ParseError(e.to_string()))?;
- return Ok(data);
+ if let Ok(file) = archive.by_name("dwarf") {
+ return budget.read(file);
}
// Old format: full dSYM bundle with Contents/Resources/DWARF/<name>
// TODO(2026-09-24): Remove this fallback once all old uploads have expired.
for i in 0..archive.len() {
- let mut file = archive
+ let file = archive
.by_index(i)
.map_err(|e| NativeError::ParseError(e.to_string()))?;
let name = file.name().to_string();
if name.contains("/Contents/Resources/DWARF/") && !name.ends_with('/') {
- let mut data = Vec::new();
- file.read_to_end(&mut data)
- .map_err(|e| NativeError::ParseError(e.to_string()))?;
- return Ok(data);
+ return budget.read(file);
}
}
@@ -298,7 +389,19 @@ pub struct SymbolInfo {
/// `ElfDebugInfo` bundles (uploaded via `posthog-cli debug-symbols upload`)
/// and `AppleDsym` bundles (uploaded via `posthog-cli dsym upload`), so
/// native frames from macOS binaries resolve against existing dSYM uploads.
-pub struct NativeProvider {}
+pub struct NativeProvider {
+ max_decompressed_bytes: usize,
+ max_extracted_bytes: usize,
+}
+
+impl NativeProvider {
+ pub fn new(config: &ResolverConfig) -> Self {
+ Self {
+ max_decompressed_bytes: config.symbol_set_max_decompressed_bytes.get(),
+ max_extracted_bytes: config.symbol_set_max_extracted_bytes.get(),
+ }
+ }
+}
#[derive(Debug, Clone)]
pub enum NativeRef {}
@@ -328,6 +431,8 @@ impl Parser for NativeProvider {
// Debug-info parsing is the heaviest CPU work in the system: zstd
// decompress, ZIP expansion, DWARF parse, and symcache conversion.
// Always offload from the tokio runtime.
+ let max_decompressed_bytes = self.max_decompressed_bytes;
+ let max_extracted_bytes = self.max_extracted_bytes;
tokio::task::spawn_blocking(move || -> Result<ParsedNativeSymbols, ResolveError> {
let _permit = permit;
// Slice selection invariant: CLI dSYM uploads are one single-arch
@@ -335,22 +440,21 @@ impl Parser for NativeProvider {
// chunk_id lookup always parses the slice it names. The arm64
// preference inside the symcache conversion only kicks in for
// legacy raw-zip fat uploads, which predate native frames.
- let (zip_data, decompressed_bytes) =
- match read_symbol_data_with_byte_count::<ElfDebugInfo>(&source) {
- Ok((elf, bytes)) => (elf.data, bytes),
- Err(_) => match read_symbol_data_with_byte_count::<AppleDsym>(&source) {
- Ok((dsym, bytes)) => (dsym.data, bytes),
- // Raw ZIP fallback for dSYMs uploaded before the
- // symbol_data container was introduced.
- Err(_) => {
- let len = source.len();
- (source.to_vec(), len)
- }
- },
- };
- metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => "native")
- .record(decompressed_bytes as f64);
- ParsedNativeSymbols::from_zip_data(zip_data, decompressed_bytes).map_err(Into::into)
+ let container = read_symbol_data_with_byte_count_limited::<ElfDebugInfo>(
+ &source,
+ max_decompressed_bytes,
+ )
+ .map(|(elf, bytes)| (elf.data, bytes))
+ .or_else(|e| match e {
+ SymbolDataError::DecompressedTooLarge(_) => Err(e),
+ _ => read_symbol_data_with_byte_count_limited::<AppleDsym>(
+ &source,
+ max_decompressed_bytes,
+ )
+ .map(|(dsym, bytes)| (dsym.data, bytes)),
+ });
+ ParsedNativeSymbols::from_container(container, &source, max_extracted_bytes, "native")
+ .map_err(Into::into)
})
.await
.map_err(|e| UnhandledError::Other(format!("native debug symbol parse task failed: {e}")))?
@@ -367,7 +471,7 @@ impl Display for NativeRef {
mod test {
use std::collections::HashMap;
- use super::ParsedNativeSymbols;
+ use super::{NativeProvider, ParsedNativeSymbols};
fn symbols_with(sources: &[(&str, &str)]) -> ParsedNativeSymbols {
ParsedNativeSymbols {
@@ -413,22 +517,31 @@ mod test {
"fixture embeds an unredacted home directory"
);
}
+ let manifest =
+ serde_json::json!({"version": 1, "files": {SOURCE_PATH: "__source/main.dart"}})
+ .to_string();
let mut zip = zip::ZipWriter::new(Cursor::new(Vec::new()));
let options = zip::write::SimpleFileOptions::default();
zip.start_file("dwarf", options).unwrap();
zip.write_all(&dwarf).unwrap();
zip.start_file("__source/manifest.json", options).unwrap();
- zip.write_all(
- serde_json::json!({"version": 1, "files": {SOURCE_PATH: "__source/main.dart"}})
- .to_string()
- .as_bytes(),
- )
- .unwrap();
+ zip.write_all(manifest.as_bytes()).unwrap();
zip.start_file("__source/main.dart", options).unwrap();
zip.write_all(SOURCE.as_bytes()).unwrap();
let data = zip.finish().unwrap().into_inner();
-
- let symbols = ParsedNativeSymbols::from_zip_data(data.clone(), data.len()).unwrap();
+ let extracted_bytes = dwarf.len() + manifest.len() + SOURCE.len();
+
+ // A budget one byte short of the bundle leaves no room for the sources, and the
+ // symbols still resolve without them.
+ let without_sources =
+ ParsedNativeSymbols::from_zip_data(data.clone(), data.len(), extracted_bytes - 1)
+ .unwrap();
+ assert_eq!(without_sources.lookup(address).unwrap()[0].line, 7);
+ assert_eq!(without_sources.get_source(SOURCE_PATH), None);
+
+ let symbols =
+ ParsedNativeSymbols::from_zip_data(data.clone(), data.len(), extracted_bytes)
+ .unwrap();
let frame = symbols.lookup(address).unwrap().remove(0);
assert_eq!(frame.display_name, "main");
assert_eq!(frame.full_path.as_deref(), Some(SOURCE_PATH));
@@ -447,6 +560,110 @@ mod test {
}
}
+ #[tokio::test]
+ async fn parse_fails_when_a_bundle_expands_past_its_size_limit() {
+ use std::{
+ io::{Cursor, Write},
+ num::NonZeroUsize,
+ };
+
+ use posthog_symbol_data::{write_symbol_data, AppleDsym, ElfDebugInfo, SymbolDataError};
+
+ use crate::{
+ core::config::ResolverConfig,
+ error::{AppleError, FrameError, NativeError, ResolveError},
+ symbolication::symbol_store::{apple::AppleProvider, ParsePermit, Parser},
+ };
+
+ const LIMIT: usize = 1024;
+ const EXTRACTED_LIMIT: usize = 2 * LIMIT;
+ let mut config = ResolverConfig::init_with_defaults().unwrap();
+ config.symbol_set_max_decompressed_bytes = NonZeroUsize::new(LIMIT).unwrap();
+ config.symbol_set_max_extracted_bytes = NonZeroUsize::new(EXTRACTED_LIMIT).unwrap();
+
+ let oversized_container = write_symbol_data(ElfDebugInfo {
+ data: vec![0; 64 * LIMIT],
+ })
+ .unwrap();
+ let oversized_dsym = write_symbol_data(AppleDsym {
+ data: vec![0; 64 * LIMIT],
+ })
+ .unwrap();
+
+ let oversized_entry = |name: &str| {
+ let mut zip = zip::ZipWriter::new(Cursor::new(Vec::new()));
+ zip.start_file(name, zip::write::SimpleFileOptions::default())
+ .unwrap();
+ zip.write_all(&vec![0; 64 * LIMIT]).unwrap();
+ let zip_data = zip.finish().unwrap().into_inner();
+ assert!(zip_data.len() <= LIMIT);
+ write_symbol_data(ElfDebugInfo { data: zip_data }).unwrap()
+ };
+
+ let frame_error = |result: Result<ParsedNativeSymbols, ResolveError>| match result {
+ Err(ResolveError::ResolutionError(e)) => e,
+ Err(e) => panic!("{e:?}"),
+ Ok(_) => panic!("parse succeeded"),
+ };
+ let too_large = |limit: usize| SymbolDataError::DecompressedTooLarge(limit as u64);
+
+ let provider = NativeProvider::new(&config);
+ for (source, expected_limit) in [
+ (oversized_container, LIMIT),
+ (oversized_dsym.clone(), LIMIT),
+ (oversized_entry("dwarf"), EXTRACTED_LIMIT),
+ (
+ oversized_entry("App.dSYM/Contents/Resources/DWARF/App"),
+ EXTRACTED_LIMIT,
+ ),
+ ] {
+ assert_eq!(
+ frame_error(provider.parse(source.into(), ParsePermit::none()).await),
+ FrameError::Native(NativeError::DataError(too_large(expected_limit)))
+ );
+ }
+
+ assert_eq!(
+ frame_error(
+ AppleProvider::new(&config)
+ .parse(oversized_dsym.into(), ParsePermit::none())
+ .await
+ ),
+ FrameError::Apple(AppleError::DataError(too_large(LIMIT)))
+ );
+ }
+
+ #[test]
+ fn extraction_budget_charges_bytes_from_a_failed_read() {
+ use std::io::{Cursor, Read};
+
+ use super::ExtractionBudget;
+
+ struct FailsAtEnd(Cursor<Vec<u8>>);
+ impl Read for FailsAtEnd {
+ fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
+ match self.0.read(buf)? {
+ 0 => Err(std::io::Error::other("checksum mismatch")),
+ n => Ok(n),
+ }
+ }
+ }
+
+ let mut budget = ExtractionBudget::new(150);
+ let entry = || FailsAtEnd(Cursor::new(vec![0; 100]));
+ assert_eq!(budget.read_optional(entry()).unwrap(), None);
+ assert!(budget.read_optional(entry()).is_err());
+ }
+
+ #[test]
+ fn cache_counts_bundled_sources_past_the_container_size() {
+ use super::Countable;
+
+ let source = "x".repeat(1000);
+ let symbols = symbols_with(&[("/src/main.c", &source)]);
+ assert!(symbols.byte_count() >= source.len());
+ }
+
#[test]
fn source_lookup_matches_file_name_components_not_suffixes() {
let symbols = symbols_with(&[("/src/foobar.c", "foo"), ("/abs/path/Foo.swift", "swift")]);
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs b/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
index 2fa2fa25d569..8a05c76e3cfe 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/proguard.rs
@@ -2,12 +2,15 @@ use std::fmt::Display;
use async_trait::async_trait;
use bytes::Bytes;
-use posthog_symbol_data::{read_symbol_data_with_byte_count, ProguardMapping};
+use posthog_symbol_data::{read_symbol_data_with_byte_count_limited, ProguardMapping};
use crate::{
+ core::config::ResolverConfig,
error::{ProguardError, ResolveError, UnhandledError},
metric_consts::SYMBOL_SET_DECOMPRESSED_BYTES,
- symbolication::symbol_store::{caching::Countable, Fetcher, ParsePermit, Parser},
+ symbolication::symbol_store::{
+ caching::Countable, record_size_limit_exceeded, Fetcher, ParsePermit, Parser,
+ },
};
pub struct FetchedMapping {
@@ -20,7 +23,17 @@ impl Countable for FetchedMapping {
}
}
-pub struct ProguardProvider {}
+pub struct ProguardProvider {
+ max_decompressed_bytes: usize,
+}
+
+impl ProguardProvider {
+ pub fn new(config: &ResolverConfig) -> Self {
+ Self {
+ max_decompressed_bytes: config.symbol_set_max_decompressed_bytes.get(),
+ }
+ }
+}
// Enum it's impossible to construct, allowing us to type-brand an OrChunkID for proguard maps specifically.
// Chunk ID's aren't injected into proguard maps and java projects the way they are in e.g. JS projects,
@@ -54,10 +67,13 @@ impl Parser for ProguardProvider {
) -> Result<FetchedMapping, ResolveError> {
// zstd decompress + ProguardCache::write are CPU-bound; offload from the tokio
// runtime so a large mapping doesn't block other in-flight requests.
+ let max_decompressed_bytes = self.max_decompressed_bytes;
tokio::task::spawn_blocking(move || -> Result<FetchedMapping, ResolveError> {
let _permit = permit;
let (map, decompressed_bytes): (ProguardMapping, usize) =
- read_symbol_data_with_byte_count(&source).map_err(ProguardError::DataError)?;
+ read_symbol_data_with_byte_count_limited(&source, max_decompressed_bytes)
+ .inspect_err(|e| record_size_limit_exceeded(e, "proguard", "container"))
+ .map_err(ProguardError::DataError)?;
metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => "proguard")
.record(decompressed_bytes as f64);
Ok(FetchedMapping::new(map, decompressed_bytes)?)
@@ -105,7 +121,7 @@ impl Display for ProguardRef {
#[cfg(test)]
mod tests {
- use posthog_symbol_data::write_symbol_data;
+ use posthog_symbol_data::{read_symbol_data_with_byte_count, write_symbol_data};
use super::*;
diff --git a/rust/cymbal/src/core/symbolication/symbol_store/sourcemap.rs b/rust/cymbal/src/core/symbolication/symbol_store/sourcemap.rs
index fde51db366e2..4e7f39f1f8cd 100644
--- a/rust/cymbal/src/core/symbolication/symbol_store/sourcemap.rs
+++ b/rust/cymbal/src/core/symbolication/symbol_store/sourcemap.rs
@@ -9,7 +9,9 @@ use async_trait::async_trait;
use base64::Engine;
use bytes::Bytes;
use futures::StreamExt;
-use posthog_symbol_data::{read_symbol_data_with_byte_count, write_symbol_data, SourceAndMap};
+use posthog_symbol_data::{
+ read_symbol_data_with_byte_count_limited, write_symbol_data, SourceAndMap,
+};
use reqwest::Url;
use serde::Deserialize;
use sourcemap::{DecodedMap, SourceMap};
@@ -31,7 +33,7 @@ use super::{
caching::Countable,
chunk_id::{load_symbol_set_data, SymbolSetLoadResult},
dart_minified_names::parse_dart_minified_names,
- BlobClient, Fetcher, ParsePermit, Parser,
+ record_size_limit_exceeded, BlobClient, Fetcher, ParsePermit, Parser,
};
pub struct SourcemapProvider {
@@ -39,6 +41,7 @@ pub struct SourcemapProvider {
pub chunk_id_rescue: Option<ChunkIdRescue>,
pub max_response_bytes: usize,
allow_internal_ips: bool,
+ max_decompressed_bytes: usize,
}
/// How many redirects we follow. Installing a custom policy to vet each hop replaces reqwest's
@@ -363,6 +366,7 @@ impl SourcemapProvider {
chunk_id_rescue: None,
max_response_bytes: config.sourcemap_max_response_bytes,
allow_internal_ips,
+ max_decompressed_bytes: config.symbol_set_max_decompressed_bytes.get(),
}
}
@@ -499,14 +503,17 @@ impl Parser for SourcemapProvider {
type Err = ResolveError;
async fn parse(&self, data: Bytes, permit: ParsePermit) -> Result<Self::Set, Self::Err> {
let start = common_metrics::timing_guard(SOURCEMAP_PARSE, &[]);
- // `read_symbol_data_with_byte_count` zstd-decompresses a potentially large blob, and
- // `SourceMapCacheWriter::new` is a CPU-bound serializer. Running them on a tokio
+ // `read_symbol_data_with_byte_count_limited` zstd-decompresses a potentially large blob,
+ // and `SourceMapCacheWriter::new` is a CPU-bound serializer. Running them on a tokio
// worker blocks the runtime; offload to a blocking thread instead.
+ let max_decompressed_bytes = self.max_decompressed_bytes;
let smc =
tokio::task::spawn_blocking(move || -> Result<OwnedSourceMapCache, ResolveError> {
let _permit = permit;
let (sam, decompressed_bytes): (SourceAndMap, usize) =
- read_symbol_data_with_byte_count(&data).map_err(JsResolveErr::JSDataError)?;
+ read_symbol_data_with_byte_count_limited(&data, max_decompressed_bytes)
+ .inspect_err(|e| record_size_limit_exceeded(e, "sourcemap", "container"))
+ .map_err(JsResolveErr::JSDataError)?;
metrics::histogram!(SYMBOL_SET_DECOMPRESSED_BYTES, "kind" => "sourcemap")
.record(decompressed_bytes as f64);
OwnedSourceMapCache::from_source_and_map(sam, decompressed_bytes)
@@ -849,6 +856,7 @@ mod test {
use crate::error::FrameError;
use common_dns::test_util::capture_oob_logs;
use httpmock::MockServer;
+ use posthog_symbol_data::read_symbol_data_with_byte_count;
use sourcemap::SourceMapBuilder;
const MINIFIED: &[u8] = include_bytes!("../../../../tests/static/chunk-PGUQKT6S.js");
diff --git a/rust/cymbal/src/core/types/langs/apple.rs b/rust/cymbal/src/core/types/langs/apple.rs
index 42c636d5e3e4..ae885bdec528 100644
--- a/rust/cymbal/src/core/types/langs/apple.rs
+++ b/rust/cymbal/src/core/types/langs/apple.rs
@@ -481,7 +481,7 @@ mod test {
config.object_storage_bucket.clone(),
);
- let hmp = HermesMapProvider {};
+ let hmp = HermesMapProvider::new(&config);
let hmp = ChunkIdFetcher::new(
hmp,
client.clone(),
@@ -490,21 +490,21 @@ mod test {
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let apple = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let native = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
@@ -649,25 +649,25 @@ mod test {
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/core/types/langs/hermes.rs b/rust/cymbal/src/core/types/langs/hermes.rs
index 8a8d98128f9b..eaaac5f8cbcc 100644
--- a/rust/cymbal/src/core/types/langs/hermes.rs
+++ b/rust/cymbal/src/core/types/langs/hermes.rs
@@ -365,7 +365,7 @@ mod test {
let client = Arc::new(client);
- let hmp = HermesMapProvider {};
+ let hmp = HermesMapProvider::new(&config);
let hmp = ChunkIdFetcher::new(
hmp,
client.clone(),
@@ -382,21 +382,21 @@ mod test {
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let apple = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
);
let native = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/core/types/langs/java.rs b/rust/cymbal/src/core/types/langs/java.rs
index 2dc79339e2f9..d5e6a7b13edd 100644
--- a/rust/cymbal/src/core/types/langs/java.rs
+++ b/rust/cymbal/src/core/types/langs/java.rs
@@ -542,20 +542,29 @@ mod tests {
bucket.clone(),
);
let hmp = ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(&config),
client.clone(),
db.clone(),
bucket.clone(),
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
bucket.clone(),
);
- let apple =
- ChunkIdFetcher::new(AppleProvider {}, client.clone(), db.clone(), bucket.clone());
- let native = ChunkIdFetcher::new(NativeProvider {}, client.clone(), db.clone(), bucket);
+ let apple = ChunkIdFetcher::new(
+ AppleProvider::new(&config),
+ client.clone(),
+ db.clone(),
+ bucket.clone(),
+ );
+ let native = ChunkIdFetcher::new(
+ NativeProvider::new(&config),
+ client.clone(),
+ db.clone(),
+ bucket,
+ );
Catalog::new(smp, hmp, pgp, apple, native)
}
diff --git a/rust/cymbal/src/core/types/langs/native.rs b/rust/cymbal/src/core/types/langs/native.rs
index 901e3e3b4b41..aaf9e3969b0b 100644
--- a/rust/cymbal/src/core/types/langs/native.rs
+++ b/rust/cymbal/src/core/types/langs/native.rs
@@ -699,25 +699,25 @@ pub(crate) mod test_support {
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- HermesMapProvider {},
+ HermesMapProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
),
ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config),
client.clone(),
db.clone(),
config.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/exception.rs b/rust/cymbal/src/modes/processing/stages/resolution/exception.rs
index c389aee6d2d2..610c98e8ea8b 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/exception.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/exception.rs
@@ -80,7 +80,7 @@ mod test {
let client = Arc::new(client);
- let hmp = HermesMapProvider {};
+ let hmp = HermesMapProvider::new(&config.resolver);
let hmp = ChunkIdFetcher::new(
hmp,
client.clone(),
@@ -97,21 +97,21 @@ mod test {
);
let pgp = ChunkIdFetcher::new(
- ProguardProvider {},
+ ProguardProvider::new(&config.resolver),
client.clone(),
db.clone(),
config.resolver.object_storage_bucket.clone(),
);
let apple = ChunkIdFetcher::new(
- AppleProvider {},
+ AppleProvider::new(&config.resolver),
client.clone(),
db.clone(),
config.resolver.object_storage_bucket.clone(),
);
let native = ChunkIdFetcher::new(
- NativeProvider {},
+ NativeProvider::new(&config.resolver),
client.clone(),
db.clone(),
config.resolver.object_storage_bucket.clone(),
diff --git a/rust/cymbal/src/modes/resolution/README.md b/rust/cymbal/src/modes/resolution/README.md
index a470ba3558b9..3701a6e7dc96 100644
--- a/rust/cymbal/src/modes/resolution/README.md
+++ b/rust/cymbal/src/modes/resolution/README.md
@@ -127,13 +127,15 @@ All variables are prefixed `CYMBAL_REMOTE_RESOLUTION_` and live on `cymbal::conf
| `SYMBOL_SET_MAX_CONCURRENT_LARGE_PARSES` | `2` | Cap on concurrent large symbol set parses across all providers. Each large parse reserves at least this share of the memory budget. |
| `SYMBOL_SET_PARSE_MEMORY_BUDGET_BYTES` | `1000000000` | Shared budget for the estimated peak memory of large parses. A parse waits until its estimate fits. A parse estimated above the whole budget runs alone. |
| `SYMBOL_SET_PARSE_MEMORY_MULTIPLIER` | `8` | Estimated peak parse memory, as a multiple of the decompressed symbol set size. |
+| `SYMBOL_SET_MAX_DECOMPRESSED_BYTES` | `536870912` | Cap on the decompressed size of a symbol set container. A larger container fails to parse. |
+| `SYMBOL_SET_MAX_EXTRACTED_BYTES` | `1610612736` | Cap on the bytes a native or Apple parse reads out of the symbol set's ZIP, summed over every entry it reads. A DWARF entry past the cap fails the parse. Bundled sources past the cap are dropped, and the frame still resolves. |
| `MAX_ITEM_CONCURRENCY` | `64` | Process-wide cap on concurrently processed exception items. Excess items receive `ERROR_KIND_OVERLOADED`. |
| `SERVICE_INSTANCE_ID` | random UUID | Identifier surfaced to callers via `LoadEvent` on the Subscribe stream. |
| `SUBSCRIBE_TICK_INTERVAL_MS` | `1000` | Default `LoadEvent` heartbeat cadence when callers do not suggest one. Load events may be emitted earlier when draining changes or in-flight load crosses coarse thresholds. |
| `SUBSCRIBE_MIN_TICK_MS` | `100` | Lower bound for the Subscribe tick cadence. |
| `SUBSCRIBE_MAX_TICK_MS` | `10000` | Upper bound for the Subscribe tick cadence. |
-All four symbol set parse settings must be positive integers. Invalid values prevent the service from starting.
+All six symbol set parse settings must be positive integers. Invalid values prevent the service from starting.
The server inherits the narrow subset of cymbal's env-var surface needed by `build_symbol_resolver` and internal gRPC authentication: `INTERNAL_API_SECRET`, Postgres, object storage, symbol-store cache/resolver tuning, and outbound HTTP controls. Frame result cache knobs such as `FRAME_RESOLVED_TTL_SECONDS` and `FRAME_UNRESOLVED_TTL_SECONDS` are read through cymbal's shared symbol resolver config, not duplicated in `cymbal-resolution`'s own `Config`. It does not connect to Kafka, Redis, or the signals API.
diff --git a/rust/cymbal/tests/resolve.rs b/rust/cymbal/tests/resolve.rs
index 3cea7fa7f02f..82e95452015d 100644
--- a/rust/cymbal/tests/resolve.rs
+++ b/rust/cymbal/tests/resolve.rs
@@ -127,19 +127,19 @@ async fn end_to_end_resolver_test() {
let wrapped = NoOpChunkIdFetcher { inner: sourcemap };
let hmp = NoOpChunkIdFetcher {
- inner: HermesMapProvider {},
+ inner: HermesMapProvider::new(&config.resolver),
};
let pgp = NoOpChunkIdFetcher {
- inner: ProguardProvider {},
+ inner: ProguardProvider::new(&config.resolver),
};
let apple = NoOpChunkIdFetcher {
- inner: AppleProvider {},
+ inner: AppleProvider::new(&config.resolver),
};
let native = NoOpChunkIdFetcher {
- inner: NativeProvider {},
+ inner: NativeProvider::new(&config.resolver),
};
let catalog = Catalog::new(Caching::new(wrapped, cache), hmp, pgp, apple, native);