-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Crash DoTargetCombatCondition #2320
Comments
Can you please use issue template? |
@thexamx I do not really know what it has changed, but here you are |
Could you please share the script you are having issue with? It seems like a double free and you are probably adding the same condition twice. |
No, it seems you are using incorrect list type for ConditionList in CombatParam. Don't you see it ? |
You have extra parenthesis after |
It is issue that happened while copying the script. The script is correct itself. There is a bug in a repo connected with forward_list and ConditionList in CombatParams |
Does not crash. |
It is, function doTargetCombatCondition implies damage dealt by specific player. |
Confirmed, it is crashing. |
It can't be an issue with the structure itself, as STL is rock solid and thoroughly tested. You can't declare a condition outside a function as it will be cleared when removed and you will try to reuse it later. Instantiate the condition right before using it, i.e. function onStepIn(creature, item, position, fromPosition)
creature:removeCondition(CONDITION_FIRE)
local condition = Condition(CONDITION_FIRE)
condition:addDamage(7, 9000, -10)
creature:addCondition(condition)
return true
end And you should be clear. |
This has to be done via doTargetCombatCondition , as your example does not provide feature called setting damage dealer. And you are using forward_list in the wrong way |
As you wish:
And I personally hate forward list, but why do you keep saying "using in the wrong way"? |
The code you provided me crashes the server if you step on a field 2 times (did not check). That's the point. No LUA code should crash the server. |
You didn't answer my question. No code should have bugs, yet no code is free of bugs. What is wrong with the usage of forward_list here? No issue should go without answers or fixes. |
I do not really know what exactly happens the bug. I suspect this is connected with doRemoveCondition and its erase function. But I do not want to waste the time debugging it. I have fixed it by changing: Combat.h
to
And by replacing in luascript.cpp
to
Works as expected. |
@infister Lua* |
@infister That's not a fix, that's introducing a memory leak. A quick fix would be to change two calls in luascript.cpp from: btw. since clone() is returning an owning pointer, it should return unique_ptr |
That's what I suspected, you are getting a double free and it fixes because you miss the second delete by removing the Also, it should use a |
Cloning condition fixes the crash, so I recommend introducing it in the code. |
Sorry for this little reference mess, got lost in terminals. I'm not sure if we should change std::forward_list to std::vector, since for some reason it is expected to push the condition to the beginning. What is interesting tho is that we can add multiple conditions to combat, but the function is called "setCondition" as if only one was supported. |
Please update your source. It should be fixed with the latest commit. |
Before creating an issue, please ensure:
support matter (use https://otland.net/forums/support.16/ for support)
Steps to reproduce (include any configuration/script required to reproduce)
Expected behaviour
Not crash
Actual behaviour
Crash
Environment
Ubuntu 16
The text was updated successfully, but these errors were encountered: