Skip to content

Add proactive stack overflow detection via MaxCallDepth + tests#317

Open
ModMaker101 wants to merge 1 commit into
nuskey8:mainfrom
ModMaker101:feat/168-stackoverflow-protection
Open

Add proactive stack overflow detection via MaxCallDepth + tests#317
ModMaker101 wants to merge 1 commit into
nuskey8:mainfrom
ModMaker101:feat/168-stackoverflow-protection

Conversation

@ModMaker101
Copy link
Copy Markdown

Description

Adds proactive stack overflow detection to prevent process terminating native StackOverflowException and enable sandboxing use.

Changes

  • Add MaxCallDepth property to LuaState.
  • Add native stack check in Call and TailCall before pushing frames
  • Move logical depth check into PushCallStackFrames to cover all the call sites.
  • Make LuaStackOverflowException public so users can catch it by type.

Tests:

Added the following:

  • ExceedingMaxCallDepth_ThrowsLuaRuntimeException
  • ExceedingMaxCallDepth_WithPCall_ReturnsErrorMessage
  • UnderMaxCallLimit_Succeeds
  • DefaultMaxCallDepth_AllowsDeepRecursion

All tests passed. Ready for review.

@ModMaker101
Copy link
Copy Markdown
Author

And solves #168.

@ModMaker101
Copy link
Copy Markdown
Author

@nuskey8 Mind reviewing this?

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.

1 participant