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

Terminate only when callback wasn't set #37

Open
Xottab-DUTY opened this issue Jan 12, 2018 · 4 comments
Open

Terminate only when callback wasn't set #37

Xottab-DUTY opened this issue Jan 12, 2018 · 4 comments

Comments

@Xottab-DUTY
Copy link

Xottab-DUTY commented Jan 12, 2018

Currently when luabind exceptions are disabled, program terminates always on lua errors.
Maybe we can allow user to tell luabind crash only when error callback wan't set?

For now, I have modified the code for me: https://github.com/Xottab-DUTY/luabind-deboostified/commit/ee8a074be60ab849b2f4c7bba79b8c6001bf74c3
But this changes original behavior. We need a save safe method to change that behaviour.

@decimad
Copy link
Owner

decimad commented Jan 17, 2018

I must confess I don't know the implications, since I generally only use the exception path.
That being said, my understanding was that the handler needs to do some stack unwinding / longjump equivalent to the exception mechanism, since the normal flow of execution is disrupted by a failed operation. In this case, the assertion is only hit if the error handler fails to do that. Am I on the completely wrong track?

@Xottab-DUTY
Copy link
Author

Yes, we can make error handler to return boolean value, and if it's false (or callback wasn't even set), then calls to std::terminate.

Implications:

I just need to mimic old luabind (version ~beta7-devel.rc4) behaviour. When the script error occurs old luabind just hangs the script execution and you can continue to play the game. Engine's debug manager will show in the log that's something went wrong, but game won't be crashed, because script errors are not critical.
Current version of luabind just calls to std::terminate which makes script errors critical.

@decimad
Copy link
Owner

decimad commented Jan 21, 2018

Okay, I think I will replace cast_failed_callback and error_callback with std::function<bool( ... )> counterparts and disable terminate on true return value (ie. it has "disable terminate" semantics).
Would that be OK?

@Xottab-DUTY
Copy link
Author

Sure

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

No branches or pull requests

2 participants