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

Stack pointer validation for call function/method opcodes #237

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

MiranDMC
Copy link
Collaborator

@MiranDMC MiranDMC commented Nov 24, 2024

Can it backfire in any way? Plugin compiled in debug configuration throws similar exceptions\error messages when stack pointer is left modified.
Does it make sense to allow scripts in legacy mode to not pop after call?
image

@MiranDMC MiranDMC requested a review from x87 November 24, 2024 22:40
@MiranDMC MiranDMC changed the title Added stack pointer validation for call function/method opcodes. Stack pointer validation for call function/method opcodes Nov 27, 2024
@x87
Copy link

x87 commented Nov 27, 2024

This is a very complicated area and I would better avoid making changes here. We should encourage people using new foreign function syntax in SB with proper calling convention and clearly defined arguments, and avoid dealing with raw commands like that.

@MiranDMC
Copy link
Collaborator Author

This is a very complicated area and I would better avoid making changes here. We should encourage people using new foreign function syntax in SB with proper calling convention and clearly defined arguments, and avoid dealing with raw commands like that.

Yes, but new syntax also relay on user specifying correct calling convention. As said module build in debug mode automatically throws exceptions when such scenario occurs.
I'm just not ASM fluent to the point to be absolute sure, there is not single case where exception from that rule occurs. Can you think of single case where modified stack pointer after return from call is intended behavior?

@x87
Copy link

x87 commented Nov 27, 2024

No idea. Possibly not, but I can't guarantee.

Calling external code is a precise operation. You must do it right. This is not something we should correct.

@MiranDMC
Copy link
Collaborator Author

No idea. Possibly not, but I can't guarantee.

Calling external code is a precise operation. You must do it right. This is not something we should correct.

This is how the debug error itself looks:
image
Might be worth to read more about that (exact circumstances when it occurs) and reflect that behavior.
Topic for further investigation in future.

Feature like that would be beneficial. So far the error did not occurred for me, but I have another project where I mess with RenderWare and it sometimes crashes. Not sure if it could be caused by stack corruption somewhere.

@MiranDMC MiranDMC marked this pull request as draft November 27, 2024 15:58
@x87
Copy link

x87 commented Nov 27, 2024

I was about to say after some thinking, maybe we can keep it and see if user would complain.

The error message in VS is much more helpful that what CLEO provides. Maybe we can use the exact wording + usual script info.

@MiranDMC MiranDMC marked this pull request as ready for review November 27, 2024 16:14
@MiranDMC
Copy link
Collaborator Author

MiranDMC commented Nov 27, 2024

I was about to say after some thinking, maybe we can keep it and see if user would complain.

The error message in VS is much more helpful that what CLEO provides. Maybe we can use the exact wording + usual script info.

Well the VS error message does not seem to be much more helpful. All the script user needs to know is the script command and information the "pop" argument was too small/big.

@MiranDMC
Copy link
Collaborator Author

image
Updated.

@MiranDMC MiranDMC merged commit aba9aa8 into master Nov 27, 2024
1 check passed
@MiranDMC MiranDMC deleted the stack_state_verification_for_call_function_opcodes branch November 27, 2024 17:13
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.

2 participants