Alright, I'm not sure I got all the details correct here, but here goes.. asCExprValue::stackOffset is a type short (which is signed):
Which is used here:
In my case, stackOffset is 0x9c4e, which as a signed value would be -25522, but the length of globalProperties is 40015. Should stackOffset be turned into an unsigned short to fix this problem? (eg. 0x9c4e = 40014)
Additionally, it seems kinda weird that globalProperties has 40k items. My reproduction case is that I have many different modules with many scripts - I don't really want to make a new asIScriptEngine for every module either (there's a LOT of bindings in my script engine). I never thought I'd reach any kind of hard Angelscript limitations like this! Any thoughts/advice on that would be welcome.
I just tried changing it to an unsigned short which does fix the problem in my reproduction case for now. In the long term however this won't be a great solution I think.
(Relevant bug report: https://github.com/openplanet-nl/issues/issues/60)