twomice / com.joineryhq.reltoken

CiviCRM extension: Provides tokens for any related contact, for all available contact tokens. E.g., to get the spouse's first name, or parent's marriage date.
Other
1 stars 5 forks source link

Causes Apache Segmentation Fault with CiviCRM 5.44 #18

Closed bmango closed 2 years ago

bmango commented 2 years ago

After upgrading to CiviCRM 5.44 on Drupal 8.9.20, when trying to send an email to individual contacts using Actions > Send Email from the main menu, I was then getting a Network Error message. Looking at the syslog it showed there was an apache segfault. I narrowed it down to this extension by disabling and re-enabling each extension one by one. I was also able to re-create the error on a fresh CiviCRM install with Drupal 8.

In case it is helpful, I'm attaching the last section of output from an xdebug dump for the error:

AH01071: Got error 'ore/CRM/Contact/Tokens.php:73PHP message: PHP 237. CRM_Contact_Tokens->getHookTokens() /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Contact/Tokens.php:116PHP message: PHP 238. CRM_Utils_Hook::tokens($tokens = []) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Contact/Tokens.php:715PHP message: PHP 239. CRM_Utils_Hook->invoke($names = [0 => 'tokens'], $arg1 = [], $arg2 = NULL, $arg3 = NULL, $arg4 = NULL, $arg5 = NULL, $arg6 = NULL, $fnSuffix = 'civicrm_tokens') /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php:857PHP message: PHP 240. Civi\\Core\\CiviEventDispatcher->dispatch($eventName = 'hook_civicrm_tokens', $event = class Civi\\Core\\Event\\GenericHookEvent { protected $hookValues = [0 => [...]]; protected $hookFields = [0 => 'tokens']; protected $hookFieldsFlip = ['tokens' => 0]; private $returnValues = []; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php:167PHP message: PHP 241. Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch($eventName = 'hook_civicrm_tokens', $event = class Civi\\Core\\Event\\GenericHookEvent { protected $hookValues = [0 => [...]]; protected $hookFields = [0 => 'tokens']; protected $hookFieldsFlip = ['tokens' => 0]; private $returnValues = []; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php:198PHP message: PHP 242. Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch($listeners = [0 => [0 => '\\\\Civi\\\\Core\\\\CiviEventDispatcher', 1 => 'delegateToUF']], $eventName = 'hook_civicrm_tokens', $event = class Civi\\Core\\Event\\GenericHookEvent { protected $hookValues = [0 => [...]]; protected $hookFields = [0 => 'tokens']; protected $hookFieldsFlip = ['tokens' => 0]; private $returnValues = []; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/symfony/event-dispatcher/EventDispatcher.php:44PHP message: PHP 243. Civi\\Core\\CiviEventDispatcher::delegateToUF($event = class Civi\\Core\\Event\\GenericHookEvent { protected $hookValues = [0 => [...]]; protected $hookFields = [0 => 'tokens']; protected $hookFieldsFlip = ['tokens' => 0]; private $returnValues = []; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }, $eventName = 'hook_civicrm_tokens', class Civi\\Core\\CiviEventDispatcher { private $autoListeners = ['civi.db.query' => 1, 'hook_civicrm_entityTypes' => 1, 'hook_civicrm_config' => 1, 'civi.invoke.auth' => 1, 'hook_civicrm_permission_check' => 1, 'hook_civicrm_xmlMenu' => 1, 'hook_civicrm_alterMenu' => 1, 'hook_civicrm_preProcess' => 1, 'hook_civicrm_alterEntityRefParams' => 1, 'civi.api.resolve' => 1, 'civi.api.authorize' => 1, 'civi.api.prepare' => 1, 'hook_civicrm_apiWrappers' => 1, 'civi.api.respond' => 1, 'hook_civicrm_optionValues' => 1, 'hook_civicrm_queryObjects' => 1, 'civi.token.list' => 1, 'hook_civicrm_tokens' => 1]; private $dispatchPolicyExact = NULL;...PHP message: PHP 244. CRM_Utils_Hook_DrupalBase->invokeViaUF($numParams = 1, $arg1 = [], $arg2 = NULL, $arg3 = NULL, $arg4 = NULL, $arg5 = NULL, $arg6 = NULL, $fnSuffix = 'civicrm_tokens') /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php:237PHP message: PHP 245. CRM_Utils_Hook->runHooks($civiModules = ['automated_cron' => 'automated_cron', 'big_pipe' => 'big_pipe', 'block' => 'block', 'block_content' => 'block_content', 'breakpoint' => 'breakpoint', 'civicrm' => 'civicrm', 'sequentialcreditnotes' => 'sequentialcreditnotes', 'greenwich' => 'greenwich', 'eventcart' => 'eventcart', 'financialacls' => 'financialacls', 'contributioncancelactions' => 'contributioncancelactions', 'recaptcha' => 'recaptcha', 'ckeditor4' => 'ckeditor4', 'legacycustomsearches' => 'legacycustomsearches', 'reltoken' => 'reltoken', 'civicrm_entity' => 'civicrm_entity', 'civicrmtheme' => 'civicrmtheme', 'ckeditor' => 'ckeditor', 'color' => 'color', 'comment' => 'comment', 'config' => 'config', 'contact' => 'contact', 'contextual' => 'contextual', 'datetime' => 'datetime', 'dblog' => 'dblog', 'devel' => 'devel', 'dynamic_page_cache' => 'dynamic_page_cache', 'editor' => 'editor', 'field' => 'field', 'field_ui' => 'field_ui', 'file' => 'file', 'filter' => 'filter', 'help' =>...PHP message: PHP 246. reltoken_civicrm_tokens($tokens = []) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php:271PHP message: PHP 247. CRM_Core_SelectValues::contactTokens() /var/www/vhosts/mydomain.tv/mydomain.biz/sites/default/files/civicrm/ext/com.joineryhq.reltoken-master/reltoken.php:9PHP message: PHP 248. Civi\\Token\\TokenProcessor->listTokens() /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/CRM/Core/SelectValues.php:578PHP message: PHP 249. Civi\\Token\\TokenProcessor->getTokens() /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/Civi/Token/TokenProcessor.php:342PHP message: PHP 250. Civi\\Core\\CiviEventDispatcher->dispatch($eventName = 'civi.token.list', $event = class Civi\\Token\\Event\\TokenRegisterEvent { protected $defaults = ['entity' => 'undefined']; protected $tokenProcessor = class Civi\\Token\\TokenProcessor { public $context = [...]; protected $dispatcher = class Civi\\Core\\CiviEventDispatcher { ... }; protected $messages = NULL; public $rowContexts = NULL; public $rowValues = NULL; protected $tokens = [...]; protected $listTokens = [...]; protected $next = 0 }; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/Civi/Token/TokenProcessor.php:328PHP message: PHP 251. Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch($eventName = 'civi.token.list', $event = class Civi\\Token\\Event\\TokenRegisterEvent { protected $defaults = ['entity' => 'undefined']; protected $tokenProcessor = class Civi\\Token\\TokenProcessor { public $context = [...]; protected $dispatcher = class Civi\\Core\\CiviEventDispatcher { ... }; protected $messages = NULL; public $rowContexts = NULL; public $rowValues = NULL; protected $tokens = [...]; protected $listTokens = [...]; protected $next = 0 }; private ${Symfony\\Component\\EventDispatcher\\Event}propagationStopped = FALSE }) /var/www/vhosts/mydomain.tv/mydomain.biz/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php:198PHP message: PHP 252. Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch($listeners = [0 => [0 => class Civi\\Token\\ImpliedContextSubscriber { ... }, 1 => 'onRegisterTokens'], 1 => [0 => class CRM_Mailing_ActionTokens { ... }, 1 => 'registerTokens'], 2 => [0 => class CRM_Activity_Tokens { ... }, 1 => 'registerTokens'], 3 => [0 => class CRM_Contact_Tokens { ... }, 1 => 'registerTokens'], 4 => [0 => class CRM_Contribute_Tokens { ... }, 1 => 'registerTokens'], 5 => [0 => class CRM_Event_Tokens { ... }, 1 => 'registerTokens'], 6 => [0 => class CRM_Mailing_Tokens { ... }, 1 => 'registerTokens'], 7 => [0 => class CRM_Member_Tokens { ... }, 1 => 'registerTokens'], 8 => [0 => class CRM_Case_Tokens { ... }, 1 => 'registerTokens'], 9 => [0 => class CRM_Event_ParticipantTokens { ... }, 1 => 'registerTokens'], 10 => [0 => class CRM_Contribute_RecurTokens { ... }, 1 => 'registerTokens'], 11 => [0 => class CRM_Core_DomainTokens { ... }, 1 => 'registerTokens']], $eventName = 'civi.token.list', $event = class C...PHP message: PHP 253. CRM_Core_EntityTokens->registerTokens($e = class Civi\\Token\\Event\\TokenRegisterEvent { protected $defaults = ['entity' => 'undefined']; protected $tokenProcessor = class Civi\\Token\\TokenProcessor { public $context = [...]; protected $dispatcher = class Civi\\Core\\CiviEventDispatcher { ... }; protected $messages = NULL; public $rowContexts = NULL; public $rowValues = NULL; protected $tokens = [...]; protected $listTokens = [...]; protected $next = 0 }

twomice commented 2 years ago

Thanks for the report. We'll look into this.

Couple of questions, if you have a moment:

  1. Just to clarify: it sounds like this extension is completely unusable on your setup -- correct?
  2. PHP version?
  3. Apache version?
  4. OS version?

Thanks @bmango !

bmango commented 2 years ago

Thanks for the quick reply!

  1. I have only checked for sending emails, but I think basically yes it's unusable
  2. PHP version 7.4.26
  3. Apache version 2.4.29
  4. OS version Ubuntu 18.04.6
MegaphoneJon commented 2 years ago

@bmango have you tried my patch #19? That fixed it for me.

@twomice - the segfauly is because the infinite loop eventually causes an OOM error.

twomice commented 2 years ago

Fixed in debed2ab5060f4e782ce1e410b30adf0a4963064 (pr #19), tagged in new version 0.3.1. Thanks @bmango and @MegaphoneJon

@bmango If this new version does not address this issue fully, please feel free to re-open this ticket.