Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

AsyncTask Issue on PHP 7

Comments in 'Plugin Development' started by RekkuzaRage, Mar 1, 2016.

  1. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I recently downloaded PHP 7 and been trying to make my core plugin work on it, everything seems to run fine except AsyncTask code. For some reason, my server always crashes when it the task reaches the onCompletion method. I haven't experienced this issue on PHP 5. Not sure what is really going on here, probably something changed in PHP/pthreads?

    Here is the crash dump, something about pthreads not able to access an object that has already been destroyed, not sure...
    Code:
    PocketMine-MP Crash Dump Sat Feb 27 22:00:23 CST 2016
    
    Error: pthreads detected an attempt to connect to an object which has already been destroyed
    File: /plugins/LeafCTF-OOP/src/rekkuzarage/leaf/ctf/tasks/onQueryTask
    Line: 142
    Type: notice
    
    THIS CRASH WAS CAUSED BY A PLUGIN
    BAD PLUGIN: LeafCTF v1.2.0
    
    Code:
    [133]             case "syncCoins":
    [134]                 $server->getPluginManager()->getPlugin("LeafCTF")->queryTaskDone($this->getMethod, $this->log, $this->getPlayer);
    [135]             break;
    [136]          
    [137]             case "syncKD":
    [138]                 $server->getPluginManager()->getPlugin("LeafCTF")->queryTaskDone($this->getMethod, $this->log, $this->getPlayer);
    [139]             break;
    [140]          
    [141]             case "syncRanks":
    [142]                 $server->getPluginManager()->getPlugin("LeafCTF")->queryTaskDone($this->getMethod, $this->log, $this->getPlayer);
    [143]             break;
    [144]          
    [145]             case "saveRanks":
    [146]                 $server->getPluginManager()->getPlugin("LeafCTF")->queryTaskDone($this->getMethod, $this->log, $this->getPlayer);
    [147]             break;
    [148]          
    [149]             case "playerRegistered":
    [150]                 $server->getPluginManager()->getPlugin("LeafCTF")->queryTaskDone($this->getMethod, $this->log, $this->getPlayer);
    [151]             break;
    [152]             
    Below is the actual code. A partial version of my core's main class and the AysncTask class. Hopefully, enough information to solve this issue
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Async Task works perfectly on my server though...
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Could you show me an example of your task? Maybe, I didn't code it correctly.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    matthww likes this.
  5. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Thanks! It is fixed now, I guess you can't pass arrays through threads with pthreads (PHP 7). Also below is a comment from Krakjoe (a developer of pthreads) that is better worded. He is basically saying that arrays will be destroyed/deleted when set as a property of a thread, please correct me if I'm wrong.
    • "array coerced to Volatile when set as member of Threaded" ~ Krakjoe
    Last edited: Mar 2, 2016
  6. MichaelM04
    Offline

    MichaelM04 Active Member Plugin Developer

    Joined:
    Nov 12, 2015
    Posts:
    213
    Plugins:
    1
    Minecraft User:
    Michael
    Live signs has this same issue
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just serialize() arrays before passing, and unserialize() when using.
    matthww and RekkuzaRage like this.
  8. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Interesting. There is always a way to do things, I guess!
  9. MichaelM04
    Offline

    MichaelM04 Active Member Plugin Developer

    Joined:
    Nov 12, 2015
    Posts:
    213
    Plugins:
    1
    Minecraft User:
    Michael
    Well of course anything is possible
    RekkuzaRage likes this.

Share This Page

Advertisement