Skip to content

feat: consider variable types at extraction - #2078

Open
szokeasaurusrex wants to merge 4 commits into
szokeasaurusrex/separate-variables-modulefrom
szokeasaurusrex/schema-float-int
Open

szokeasaurusrex wants to merge 4 commits into
szokeasaurusrex/separate-variables-modulefrom
szokeasaurusrex/schema-float-int

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

WIP change to consider variable types when extracting the variables


Stack created with GitHub Stacks CLI • Give Feedback 💬

@szokeasaurusrex
szokeasaurusrex added this pull request to stack #2079 October 2, 2026 12:50
@szokeasaurusrex szokeasaurusrex changed the title feat: consider variable values at extraction feat: consider variable types at extraction Oct 2, 2026
Comment thread crates/symbolicator-native/src/symbolication/native.rs Outdated
Comment thread crates/symbolicator-native/src/symbolication/native.rs Outdated
Comment thread crates/symbolicator-native/src/symbolication/native.rs Outdated
Comment on lines +486 to +489
let (start_truncation_notice, end_truncation_notice) = match value.truncated {
Some((count, Endian::Little)) => (Some(truncation_notice(count)), None),
Some((count, Endian::Big)) => (None, Some(truncation_notice(count))),
None => (None, None),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that makes sense, even with different endianness we're still just formatting a plain slice of memory from small to large.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is confusing?

We are considering endianness when reading this memory slice, as we don't use the general method for reading slices that does not consider the endianness. So, where to place the truncation notice does depend on endianness in this case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a slice of bytes, where the notice is doesn't depend on the endianness - it's just raw bytes. Seems like you already dealt with this though.

@linear-code

linear-code Bot commented Oct 5, 2026

Copy link
Copy Markdown

SYMBOLI-78

@szokeasaurusrex
szokeasaurusrex removed this pull request from stack #2079 October 8, 2026 09:03
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/schema-float-int branch from 89d5a70 to 819d4af Compare October 8, 2026 09:03
@szokeasaurusrex
szokeasaurusrex changed the base branch from szokeasaurusrex/variables-extraction-schema to szokeasaurusrex/separate-variables-module October 8, 2026 09:03
@szokeasaurusrex
szokeasaurusrex added this pull request to stack #2087 October 8, 2026 09:03
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/schema-float-int branch from 819d4af to 41ab4cd Compare October 8, 2026 09:31
Comment on lines +229 to +232
// TODO: Is it correct to extract both signed and unsigned chars as u8 in this way?
(Primitive(SignedChar | UnsignedChar), 1) => {
get_value!(u8, |v| format_variable!("'{}'", v.escape_ascii()))
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dav1dde is this correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review October 13, 2026 12:55
@szokeasaurusrex
szokeasaurusrex requested a review from a team as a code owner October 13, 2026 12:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b6bc016. Configure here.

Comment thread crates/symbolicator-native/src/symbolication/native_variables.rs Outdated
.find_map(|loc| resolve_value(cache, registers, memory, loc, variable.ty()));
let value = variable.locations().find_map(|loc| {
resolve_variable_value(cache, registers, memory, loc, variable.ty())
})?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing values omit variables

Medium Severity

do_extract now drops a variable when every location fails to produce a value. The name, type, and kind were already resolved, and the previous code still emitted the variable with an empty value. Those names disappear whenever memory is missing or the type is unsupported.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b6bc016. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can still emit such variables without a value. @Dav1dde what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we should, to give the user at least some confidence that what we're doing is correct, we just failed to extract the value.

Can definitely do that in a follow-up/separate ticket.

// Floating-point types. Reading f128 from memory is currently not supported, so we don't
// handle it for now.
(Primitive(Float), 4) => get_value!(f32),
(Primitive(Float), 8) => get_value!(f64),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Float JSON conversion misrepresents values

Medium Severity

Float reads go through VariableValue::value, which converts with Into<serde_json::Value>. NaN and infinities become JSON null, and f32 is widened to f64, so many finite 32-bit values pick up extra digits when serialized.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b6bc016. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it would make sense to support infinity and NaN

I am not sure about whether we should care about 32-bit values picking up additional digits when serialized. Apparently enabling arbitrary_precision may fix this; otherwise we might need custom serialization logic. Should we enable arbitrary_precision?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not enable it, we can track this is a separate issue we can come back to later if we think that's an issue with real data.

If we fix this on this end, we'd also need to make sure the frontend deals with it properly (e.g. keeps the same precision), which I doubt it does.

@szokeasaurusrex
szokeasaurusrex marked this pull request as draft October 13, 2026 13:17
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/schema-float-int branch from b6bc016 to 7466db0 Compare October 13, 2026 14:23
Comment thread crates/symbolicator-native/src/symbolication/native_variables.rs
szokeasaurusrex added a commit that referenced this pull request Oct 13, 2026
Create a separate module for extracting variables, per @Dav1dde's suggestion: #2078 (comment).
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/schema-float-int branch from 7466db0 to 9b26271 Compare October 13, 2026 15:15
@szokeasaurusrex
szokeasaurusrex removed this pull request from stack #2087 October 13, 2026 15:17
@szokeasaurusrex
szokeasaurusrex added this pull request to stack #2096 October 13, 2026 15:19
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review October 13, 2026 15:57
}
}

impl FromStr for PointerAddress {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used, I can't find a usage 🤔

If the deserialization part is unused, I would keep it out of the module for now and focus purely on serialization.

.find_map(|loc| resolve_value(cache, registers, memory, loc, variable.ty()));
let value = variable.locations().find_map(|loc| {
resolve_variable_value(cache, registers, memory, loc, variable.ty())
})?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we should, to give the user at least some confidence that what we're doing is correct, we just failed to extract the value.

Can definitely do that in a follow-up/separate ticket.

Comment on lines +160 to +161
// Actual beginning of the function is here, everything above are helper type and macro defs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Actual beginning of the function is here, everything above are helper type and macro defs.

// Floating-point types. Reading f128 from memory is currently not supported, so we don't
// handle it for now.
(Primitive(Float), 4) => get_value!(f32),
(Primitive(Float), 8) => get_value!(f64),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not enable it, we can track this is a separate issue we can come back to later if we think that's an issue with real data.

If we fix this on this end, we'd also need to make sure the frontend deals with it properly (e.g. keeps the same precision), which I doubt it does.

Comment on lines +229 to +232
// TODO: Is it correct to extract both signed and unsigned chars as u8 in this way?
(Primitive(SignedChar | UnsignedChar), 1) => {
get_value!(u8, |v| format_variable!("'{}'", v.escape_ascii()))
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

}

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub(crate) enum PointerAddress {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(crate) enum PointerAddress {
pub enum PointerAddress {

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

[variables extraction] Format numbers/bools/etc. properly into the schema

2 participants