Magic

Magic

190k Downloads

Server crash (Tornado vs Power)

Blamo27 opened this issue ยท 20 comments

commented

Hello,

My server is crashing when I try to configure a wand with the "power" property only.
When I type the command : "/wand configure power 0.24" it's working.

public void Configure(Player p, String properties, float value) {

    ItemStack stack = p.getItemInHand();

    if (instance.getMagicAPI().isWand(stack) && stack.getType() == Material.WOOD_HOE) {

        Wand wand = instance.getMagicAPI().getWand(stack);
        wand.configure(map);
        map.put(properties, value);
        wand.setDescription("");

    }
}

But if I use the tornado spell for exemple with the power applied with my plugin, the server will crash.
Can you tell me why ? :/

commented

Do you actually mean the server is crashing??

Or just an exception?

Either way, what shows up in the logs?

Unless you try to set power to something crazy like 10000000 it shouldn't have any negative impact.

commented

I disabled the part of my plugins that's configuring the wand to add "power".
Yes it's a crash : http://pastebin.com/ni4gMwkF

After this, no commands can be executed and we can talk with players.

I set the power to 0.24, I also tried to show the value with a Broadcast in my test server.
The crash occurs only when I cast the spell.

commented

Well that's pretty horrible! :(

Unfortunately I can't really tell what's going on from that crash dump. The stack points to some very odd places in the code that shouldn't really ever cause a crash- so I assume something is missing there.

The only thing I can really tell is that it crashed during a spell cast- if Magic is really the cause, it may matter what spell it was- any ideas there?

And does this happen if you just use "/wand configure power 0.24" in-game?

commented

@NathanWolf The crash ONLY occurs with the spell tornado, every other spell works fine. Also, it occurs both when the armor gives the power bonus, and when the command "/wand configure" gives the power, so the way the power is given doesn't affect this bug. And, as you know, we are on 1.8.8.

commented

@NathanWolf So, we found out how to fix the issue after all. Since it was only with the spell tornado, we modified a little bit its actions, and now it works fine. We don't know exactly why it happened, but at least everything is okay now. As always thank you for your time.

commented

Well that's good news, thank you!

I'm going to leave this open until I get a chance to debug the actual issue- Magic should never crash the server like that :(

commented

Okay ! For your information, we removed this bit of the tornado's config :

actions:
   - class: Volume
     actions:
      - class: Damage
        direction: 0,1,0
        speed: 0.2

We feared that it would affect the way the spell works, but apparently it works exactly as usual, according to our tests. So, seems fine.

commented

Ok it seems we went too fast with the testing, the issue is actually still there, the change we made didn't fix anything... So we still have this problem. :(

Do you know if there is a way to make the power effect to not apply on the tornado spell specifically ? Like, it would work normally on every spell, but would not do anything on tornado, it would not increase its damage.

commented

No, unfortunately there is not- each action handles power on its own, so this would need to be something I'd add to any action that uses power (which is a lot of them).

I'm hoping when I get to test this out I can fix whatever the root problem is. My best guess is it's velocity-related but really not sure. It's very odd that Tornado is the only spell that has an issue.

commented

You're right, I removed one of these actions, I already removed the other previously.

commented

This is fixed in Magic 6.2.4, I didn't end up changing the Tornado spell but I did fix the exponential wand power effects.

commented

@NathanWolf The last problem is that we are still on 1.8.8. :/

commented

Ah- right... well I think the only spell affected by this is tornado, so if you remove the Volume and Sphere actions from that spell config you should be fine.

commented

Indeed, it works now. Thanks !

commented

Update, the part we removed in the config didn't actually "change nothing", it did improve : the server no longer crashes, but it freezes a few seconds. So it's an improvement, but the bug is still there.

commented

Wow, yeah- it doesn't crash my server, but it's very clear there's something wrong here!

Super Tornado

That's with a power of 0.2 .. the hole goes down to bedrock.

I suspect I can find something to fix this- I'm guessing it's some interaction with the volume-in-a-volume mechanic of tornado, each of which is getting its radius bumped up. It may be I need to disable radius multipliers for wand power.

commented

Ok, so quick fix for now- please put the following in your config.yml:

max_power_radius_multiplier: 1.0
max_power_radius_multiplier_max: 1.0

That will fix the problem at the expense of nerfing wand power a little bit.

I'm going to keep looking at this, by default it was at most doubling the radius (for values of power less than or equal to 1) which shouldn't cause this insanity, so something else may be wrong here.

commented

Looking over tornado, I'm trying to remember why on earth it's got a Volume inside a Sphere ... I think maybe I was trying to make it topple trees, but this is hugely inefficient.

The core problem seems to be that the power multiplier is somehow stacking up through the iterations of the sphere... that should be fixable once I track it down. I thought I'd share this frightening/amusing debug output:

[11:08:58 INFO]: [Magic] Starting SphereAction with radius 6.0 [1.5,6.0,1.5]
[11:08:58 INFO]: [Magic] Starting VolumeAction with radius 6.0 [1.5,6.0,1.5]
[11:08:58 INFO]: [Magic] Starting VolumeAction with radius 9.0 [2.25,9.0,2.25]
[11:08:58 INFO]: [Magic] Starting VolumeAction with radius 13.5 [3.375,13.5,3.375]
[11:08:59 INFO]: [Magic] Starting VolumeAction with radius 20.25 [5.0625,20.25,5.0625]
[11:09:00 INFO]: [Magic] Starting VolumeAction with radius 30.375 [7.59375,30.375,7.59375]
[11:09:03 INFO]: [Magic] Starting VolumeAction with radius 45.5625 [11.390625,45.5625,11.390625]
[11:09:16 INFO]: [Magic] Starting VolumeAction with radius 68.34375 [17.0859375,68.34375,17.0859375]
[11:09:57 INFO]: [Magic] Starting VolumeAction with radius 102.515625 [25.62890625,102.515625,25.62890625]

... that's not good for business.

Once I figure this out I may also simplify tornado, I have to imagine I can achieve a similar effect without the nested block changes, that seems terribly inefficient even without this crazy power-multiplier bloat.

commented

Thank you for the fix, it works great now, even though it's temporary. I tried to change tornado for several hours to make it work, so this is quite a relief. By the way, personnaly we removed long ago the effect of spells such as this one on blocks : we wanted it to affect only entities. This is why we didn't report the huge mess you took a screenshot of : for us, it just suddenly crashes / freezes the server ! Anyway, thank you again.

commented

Ah, whew! Well I guess I'm glad for that, as this does leave a mess.

I think if you wanted to keep tornado customized, fix this problem, and probably make it much more efficient you could cut out all of these actions:

           - class: ChangeContext
             actions:
             - class: Sphere
               ignore_result: true
               actions:
               - class: Volume
                 actions:
                 - class: ModifyBlock
                   direction: 0,1,0
                   speed: 0.2

Right now that's doing a whole lot of work that ends in "can't change this block", I'd guess.