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

Fail to build if tasks may overflow #1890

Merged
merged 10 commits into from
Oct 9, 2024
Merged

Fail to build if tasks may overflow #1890

merged 10 commits into from
Oct 9, 2024

Conversation

mkeeter
Copy link
Collaborator

@mkeeter mkeeter commented Oct 2, 2024

(details to come, but opening as a draft to see if any of the CI-checked builds fail)

@mkeeter mkeeter force-pushed the stack-overflow-check branch 2 times, most recently from 1387f12 to b6ad2f7 Compare October 2, 2024 18:36
@mkeeter mkeeter marked this pull request as ready for review October 2, 2024 20:53
Copy link
Contributor

@lzrd lzrd left a comment

Choose a reason for hiding this comment

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

I only made one pass over this, but it looks good and is a valuable addition to the build process.

Comment on lines +1198 to +1204
let detail = cs.insn_detail(instr).map_err(|e| {
anyhow!("could not get instruction details: {e}")
})?;
if detail.groups().iter().any(|g| {
g == &InsnGroupId(InsnGroupType::CS_GRP_CALL as u8)
}) {
Copy link
Member

Choose a reason for hiding this comment

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

i am obligated by myself to ask: is this why capstone in particular? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not specifically – I was using yaxpeax earlier and was fine looking for BL opcodes, but we're using enough weird instructions that I was hitting DecodeError::Incomplete in a bunch of tasks.

Copy link
Member

Choose a reason for hiding this comment

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

huh! i'll have to take a look later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should be easy enough to test by checking out one of the earlier commits, e.g. d7fc2eb uses yaxpeax

Copy link
Collaborator

@labbott labbott left a comment

Choose a reason for hiding this comment

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

I think this should be good to go!

@@ -1656,6 +1933,7 @@ fn build(
"-C link-arg=-z -C link-arg=common-page-size=0x20 \
-C link-arg=-z -C link-arg=max-page-size=0x20 \
-C llvm-args=--enable-machine-outliner=never \
-Z emit-stack-sizes \
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you know if there is any work tracking this not being nightly only? We still have a goal (dream?) of being able to build hubris with a stable toolchain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The path to stabilization appears rocky, unfortunately:
rust-lang/rust#54192

@@ -1064,6 +1075,272 @@ fn build_task(cfg: &PackageConfig, name: &str) -> Result<()> {
.context(format!("failed to build {}", name))
}

fn task_can_overflow(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any concerns about false positives / false negatives? I guess for a false positive we'd increase the stack size unnecessarily and for a false negative, well, we're back to our old methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added more comments in 9471544 about the possibility of false positives (possible but unlikely) and negatives (possible if using dynamic dispatch).

@mkeeter mkeeter enabled auto-merge (squash) October 9, 2024 18:01
@mkeeter mkeeter merged commit 9144307 into master Oct 9, 2024
106 checks passed
@mkeeter mkeeter deleted the stack-overflow-check branch October 9, 2024 18:06
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.

4 participants