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

Safely check ucode handlers for out of range or missing opcode #473

Merged
merged 3 commits into from
Apr 7, 2024

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Apr 7, 2024

The execution of the ucode handlers would crash if a bad ucode index was loaded, or the opcode has no handler.

This first adds a bounds check for the index being within the array size of ucode_handlers, and if it isn't, trip a debug assert as the call to G_LOAD_UCODE was incorrect. Alternatively, we could move the assert to be inside gfx_set_ucode_handler.

The second is to add a contains check for the opcode on the specific ucode handler before accessing the map. If the opcode is not recognized, it silently skips over it. I'm not sure if we would also want a debug assert here, or maybe logging, thoughts?

@Kenix3
Copy link
Owner

Kenix3 commented Apr 7, 2024

Definitely a situation we want to log it out when the code is not within the map

@Archez
Copy link
Contributor Author

Archez commented Apr 7, 2024

Definitely a situation we want to log it out when the code is not within the map

What log level should we use, WARN, DEBUG?

@Kenix3
Copy link
Owner

Kenix3 commented Apr 7, 2024

Definitely a situation we want to log it out when the code is not within the map

What log level should we use, WARN, DEBUG?

I'm thinking WARN.

@Kenix3 Kenix3 merged commit d795e6a into Kenix3:main Apr 7, 2024
4 checks passed
@Archez Archez deleted the check-ucode-handlers branch April 7, 2024 20:40
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.

3 participants