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

Fix access violation in create_schematic() #11534

Merged

Conversation

Treer
Copy link
Contributor

@Treer Treer commented Aug 13, 2021

Fixes #11533, schematics saved from y locations higher than 0 would cause an access violation if layer probabilities were specified

See #11533 for more details

To do

This PR is Ready for Review.

How to test

  • Attached is a mod that reproduces the error, run /nocrashy chat command for the mod to save a schematic without crashing, and /crashy for it to cause an access violation.
  • Operations performed before create_schematic() is called can affect whether Minetest will crash, so different lua code doesn't always reproduce it, and this may also be the case across different machines.
  • Testing that layer probabilities are now correctly applied (in addition to not crashing) requires serializing the output of create_schematic() into lua and inspecting the yslice_prob table. The one i tried looked good to me.
  • I've not checked whether l_create_schematic() sanitizes the ypos it receives from lua before using it as an index. (I didn't notice any, but also don't know what the policy is)

Schematics saved from y locations greater than 0 would cause an access violation if layer probabilities were specified
@sfan5 sfan5 added @ Script API Bugfix 🐛 PRs that fix a bug labels Aug 13, 2021
@Treer Treer changed the title Fix #11533 Access violation in create_schematic() Access violation in create_schematic() Aug 13, 2021
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Looked at related code, looks correct.

@sfan5 sfan5 added One approval ✅ ◻️ Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines labels Aug 16, 2021
@sfan5 sfan5 changed the title Access violation in create_schematic() Fix access violation in create_schematic() Aug 16, 2021
src/mapgen/mg_schematic.cpp Outdated Show resolved Hide resolved
@sfan5 sfan5 merged commit 963fbd1 into minetest:master Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug One approval ✅ ◻️ @ Script API Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault when create_schematic() called with layer probabilities
2 participants