Segmentation fault (core dumped) in PHP - php

Ok, I'm running a PHP app on command line on Ubuntu, and it ends with "Segmentation fault (core dumped)".
How do I go from here to debug it? I'm pretty sure there is no memory leak as I checked it already with get_memory_usage().
Edit: Alright, as explained by Brendan and Ulricht, I tried gdb. That's not my environment at all so sorry for the oncoming newbie questions.
I ran my code under gdb and got the segfault. Here are the first 22 lines.
(gdb) bt
#0 0x00000000006f5d36 in ?? ()
#1 0x00000000006f7625 in ?? ()
#2 0x00000000006f7b68 in zend_parse_parameters ()
#3 0x0000000000610584 in zif_array_rand ()
#4 0x00000000006dd9bb in dtrace_execute_internal ()
#5 0x000000000079da15 in ?? ()
#6 0x0000000000717748 in execute_ex ()
#7 0x00000000006dd8b9 in dtrace_execute_ex ()
#8 0x000000000079e060 in ?? ()
#9 0x0000000000717748 in execute_ex ()
#10 0x00000000006dd8b9 in dtrace_execute_ex ()
#11 0x000000000079e060 in ?? ()
#12 0x0000000000717748 in execute_ex ()
#13 0x00000000006dd8b9 in dtrace_execute_ex ()
#14 0x000000000079e060 in ?? ()
#15 0x0000000000717748 in execute_ex ()
#16 0x00000000006dd8b9 in dtrace_execute_ex ()
#17 0x000000000079e060 in ?? ()
#18 0x0000000000717748 in execute_ex ()
#19 0x00000000006dd8b9 in dtrace_execute_ex ()
#20 0x000000000079e060 in ?? ()
#21 0x0000000000717748 in execute_ex ()
#22 0x00000000006dd8b9 in dtrace_execute_ex ()
According to https://bugs.php.net/bugs-generating-backtrace.php, I should get "execute" calls, instead I have "execute_ex". Same thing?
The following command anyway does not return the function name (after having done frame 6):
print (char *)(executor_globals.function_state_ptr->function)->common.function_name
Attempt to extract a component of a value that is not a structure.
Edit2: I'd appreciate knowing why the downvote. I think it's a valid question and I haven't found a similar one for PHP. If there is then you're free to comment.

There are several things to pinpoint the error, but the first is to run the executable in gdb:
> gdb /usr/bin/php
....
(gdb) run path/to/script
Note that you can also load the dumped core into gdb. Other tools for finding out what could cause the issue are strace and valgrind.

Related

PHP Laravel Exception handler issue or something else

I upgraded my application from laravel 5 to 6 and PHP version from 7 to 8.0, after upgrading I faced below pasted error and there is not abnormal behavior observed in web application and web app is working fine.I can't investigate the because of this error.
I will appreciate laravel community to help me out in this regard.
Thanks
Error:
Error Type : General Application Error
DateTime : 2023-01-13 03:03:20 Message : File Name : RouteCollection.php Error Trace : #0 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\RouteCollection->match() #1 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->findRoute() #2 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute() #3 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch() #4 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() #5 /var/www/html/laravel/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php(61): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #6 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Proengsoft\JsValidation\RemoteValidationMiddleware->handle() #7 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #8 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() #9 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #10 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() #11 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #12 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() #13 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #14 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() #15 /var/www/html/laravel/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #16 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle() #17 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #18 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then() #19 /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() #20 /var/www/html/laravel/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle() #21 {main} Line Number : 179
I tried to many hit and try by googling same error to stop it but unfortunately it didnt works for me.

error while running php artisan backup:run

Hi every one I am currently working on laravel 5.8 and recently installed spatie/laravel-backup package to backup my files and db and i did all the steps which are needed to use the package but when I run the command
php artisan backup:run it gives many errors as below
Starting backup... Dumping database u452010341_qkcg... Backup failed
because The dump process failed with exitcode 1 : General error :
'"mysqldump"' is not recognized as an internal or external command,
operable program or batch file.
#0 C:\xampp\htdocs\b\vendor\spatie\db-dumper\src\DbDumper.php(246): Spatie\DbDumper\Exceptions\DumpFailed::processDidNotEndSuccessfully(Object(Symfony\Component\Process\Process))
#1 C:\xampp\htdocs\b\vendor\spatie\db-dumper\src\Databases\MySql.php(190): Spatie\DbDumper\DbDumper->checkIfDumpWasSuccessFul(Object(Symfony\Component\Process\Process), 'C:\\xampp\\htdocs...')
#2 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Tasks\Backup\BackupJob.php(250): Spatie\DbDumper\Databases\MySql->dumpToFile('C:\\xampp\\htdocs...')
#3 [internal function]: Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup\{closure}(Object(Spatie\DbDumper\Databases\MySql), 'mysql')
#4 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Support\Collection.php(1120): array_map(Object(Closure), Array, Array)
#5 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Tasks\Backup\BackupJob.php(253): Illuminate\Support\Collection->map(Object(Closure))
#6 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Tasks\Backup\BackupJob.php(167): Spatie\Backup\Tasks\Backup\BackupJob->dumpDatabases()
#7 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Tasks\Backup\BackupJob.php(143): Spatie\Backup\Tasks\Backup\BackupJob->createBackupManifest()
#8 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Commands\BackupCommand.php(52): Spatie\Backup\Tasks\Backup\BackupJob->run()
#9 [internal function]: Spatie\Backup\Commands\BackupCommand->handle()
#10 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)
#11 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#12 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#13 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#14 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Console\Command.php(183): Illuminate\Container\Container->call(Array)
#15 C:\xampp\htdocs\b\vendor\symfony\console\Command\Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#16 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Console\Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#17 C:\xampp\htdocs\b\vendor\spatie\laravel-backup\src\Commands\BaseCommand.php(16): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\xampp\htdocs\b\vendor\symfony\console\Application.php(1012): Spatie\Backup\Commands\BaseCommand->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\xampp\htdocs\b\vendor\symfony\console\Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(Spatie\Backup\Commands\BackupCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 C:\xampp\htdocs\b\vendor\symfony\console\Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Console\Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 C:\xampp\htdocs\b\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 C:\xampp\htdocs\b\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 {main}
Backup failed because: The dump process failed with exitcode 1 : General error : '"mysqldump"' is not recognized as an internal or external command,
operable program or batch file.
I searched for solutions and found the code below:
'connections' => [
'mysql' => [
'driver' => 'mysql'
...,
'dump' => [
'dump_binary_path' => '/path/to/the/binary', // only the path, so without `mysqldump` or `pg_dump`
'use_single_transaction',
'timeout' => 60 * 5, // 5 minute timeout
'exclude_tables' =>['table1', 'table2'],`enter code here`
'add_extra_option' =>'--optionname=optionvalue',
]
],
But still I'm getting same error... I tried more than 100times, still nothing.
So any one who gone through this problem or any body who knows how to solve this please help me out.
in the code you found, where says:
'dump_binary_path' => '/path/to/the/binary',
Change to:
'dump_binary_path' => 'C:\xampp\mysql\bin',
Next time, look to the errors because int his case, the problem is well described!
Regards
Now you also need to comment this line:
//'add_extra_option' =>'--optionname=optionvalue',
working for me.

Why a core was generated when I run the code "foreach" with PHP compiled with "--enable-debug"

I read data from xml files with protobuf, and then When I run the code "foreach data", a core was generated by php-fpm: pool www,
PHP was compiled with "--enable-debug",
here is the gdb errors:
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
Core was generated by `php-fpm: pool www '.
Program terminated with signal 11, Segmentation fault.
#0 0x000000000079407b in ZEND_FE_RESET_SPEC_CV_HANDLER (execute_data=0x7ffff7fb5118) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:31510
31510 /home/wyq/php-5.6.14/Zend/zend_vm_execute.h: No such file or directory.
in /home/wyq/php-5.6.14/Zend/zend_vm_execute.h
(gdb) bt
#0 0x000000000079407b in ZEND_FE_RESET_SPEC_CV_HANDLER (execute_data=0x7ffff7fb5118) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:31510
#1 0x000000000074067a in execute_ex (execute_data=0x7ffff7fb5118) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:363
#2 0x00000000007406fc in zend_execute (op_array=0xf69868) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:388
#3 0x00000000006e5138 in zend_call_function (fci=0x7fffffff8bb0, fci_cache=0x7fffffff8b80) at /home/wyq/php-5.6.14/Zend/zend_execute_API.c:829
#4 0x00000000005ce6b7 in zif_call_user_func_array (ht=2, return_value=0x14d35c8, return_value_ptr=0x7ffff7fb4180, this_ptr=0x0, return_value_used=0)
at /home/wyq/php-5.6.14/ext/standard/basic_functions.c:4784
#5 0x0000000000741013 in zend_do_fcall_common_helper_SPEC (execute_data=0x7ffff7fb4198) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:558
#6 0x0000000000746a11 in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0x7ffff7fb4198) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:2602
#7 0x000000000074067a in execute_ex (execute_data=0x7ffff7fb4198) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:363
#8 0x00000000007406fc in zend_execute (op_array=0x7ffff7fe7d50) at /home/wyq/php-5.6.14/Zend/zend_vm_execute.h:388
#9 0x00000000006fadf5 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/wyq/php-5.6.14/Zend/zend.c:1341
#10 0x0000000000660b72 in php_execute_script (primary_file=0x7fffffffd380) at /home/wyq/php-5.6.14/main/main.c:2597
#11 0x00000000007be875 in main (argc=1, argv=0x7fffffffd5a8) at /home/wyq/php-5.6.14/sapi/fpm/fpm/fpm_main.c:1964

Laravel SQLSTATE[HY000] [2002] Connection refused but tinker works

I have a production site using Database from an Amazon Server, I have two more sites on the same server and both of them connects without issues.
On this particular site the connection to mysql is not working, I thought that the env file was missing or not being see by the laravel app but is not the case, when I run php artisan tinker and try any command it works:
DB::table('categories')->get();
=> Illuminate\Support\Collection {#842
all: [
{#828
+"id": 1,
+"parent_id": null,
+"order": 1,
+"name": "Noticias",
+"slug": "noticias",
+"created_at": "2018-01-09 19:26:32",
+"updated_at": "2018-01-09 19:26:32",
},
],
}
The App::environment() method also works:
>>> App::environment();
=> "production"
The env files clearly says APP_DEBUG=false but it is returning a lot of debug, it is like the webserver is not reading the env file besides the artisan is.
This is driving me crazy because it started failing by itself, nothing was changed on the server or the code, it's the only project that is failing.
What else can I check?
[2018-08-25 12:22:04] production.ERROR: SQLSTATE[HY000] [2002] Connection refused {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67)
[stacktrace]
#0 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(67): PDO->__construct('mysql:host=127....', 'root', 'C4f2469dcF!', Array)
#1 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(43): Illuminate\\Database\\Connectors\\Connector->createPdoConnection('mysql:host=127....', 'root', 'C4f2469dcF!', Array)
#2 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(24): Illuminate\\Database\\Connectors\\Connector->createConnection('mysql:host=127....', Array, Array)
#3 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(183): Illuminate\\Database\\Connectors\\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#5 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(915): call_user_func(Object(Closure))
#6 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(940): Illuminate\\Database\\Connection->getPdo()
#7 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(399): Illuminate\\Database\\Connection->getReadPdo()
#8 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(325): Illuminate\\Database\\Connection->getPdoForSelect(true)
#9 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(657): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}('select * from `...', Array)
#10 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#11 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from
`...', Array, Object(Closure))
#12 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select
* from `...', Array, true)
#13 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#14 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(483): Illuminate\\Database\\Query\\Builder->get(Array)
#15 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(467): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#16 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(360): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#17 /var/app/html/releases/20180824022105/app/Category.php(13): Illuminate\\Database\\Eloquent\\Model::all()
#18 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(327): App\\Category::App\\{closure}()
#19 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(304): Illuminate\\Cache\\Repository->remember('list-categories', NULL, Object(Closure))
#20 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Cache\\CacheManager->__call('remember', Array)
#21 /var/app/html/releases/20180824022105/app/Category.php(20): Illuminate\\Support\\Facades\\Facade::__callStatic('remember', Array)
#22 /var/app/html/releases/20180824022105/routes/web.php(150): App\\Category::getCategories()
#23 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(389): Illuminate\\Routing\\Router->{closure}(Object(Illuminate\\Routing\\Router))
#24 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(349): Illuminate\\Routing\\Router->loadRoutes(Object(Closure))
#25 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Routing\\Router->group(Array, Object(Closure))
#26 /var/app/html/releases/20180824022105/routes/web.php(162): Illuminate\\Support\\Facades\\Facade::__callStatic('group', Array)
#27 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(393): require('/var/www/turico...')
#28 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/Router.php(349): Illuminate\\Routing\\Router->loadRoutes('/var/www/turico...')
#29 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Routing/RouteRegistrar.php(105): Illuminate\\Routing\\Router->group(Array, '/var/www/turico...')
#30 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(56): Illuminate\\Routing\\RouteRegistrar->group('/var/www/turico...')
#31 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(40): App\\Providers\\RouteServiceProvider->mapWebRoutes()
#32 [internal function]: App\\Providers\\RouteServiceProvider->map()
#33 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#34 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#35 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#36 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#37 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(74): Illuminate\\Container\\Container->call(Array)
#38 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(33): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->loadRoutes()
#39 /var/app/html/releases/20180824022105/app/Providers/RouteServiceProvider.php(28): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->boot()
#40 [internal function]: App\\Providers\\RouteServiceProvider->boot()
#41 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#42 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#43 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#44 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#45 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(792): Illuminate\\Container\\Container->call(Array)
#46 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\\Foundation\\Application->bootProvider(Object(App\\Providers\\RouteServiceProvider))
#47 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}(Object(App\\Providers\\RouteServiceProvider), 26)
#48 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(776): array_walk(Array, Object(Closure))
#49 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#50 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(213): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
#51 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#52 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#53 /var/app/html/releases/20180824022105/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#54 /var/app/html/releases/20180824022105/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#55 {main}
"}
You should verify if you have bootstrap/cache/config.php file. If yes, it means, your config is cached. Than you can run:
php artisan config:cache
to refresh config and sync data you have set in .env or
php artisan config:clear
if you don't want to use cached config (keep in mind it's recommended to cache config on production)
The solution for me was to restart the laravel development server, ie: run php artisan serve again.
I had changed the db config after I had originally run the dev server.
I had a similar problem, I installed php7.2-mysql after I installed everything else. Tinker was working perfectly but my application would not connect.
I spent 2 hours trying to debug until a simple apache restart did the trick.
The problem is that mysql's root user can't be used anymore, since mysql v5.7. More about this here.

Alter code accessed by running cron

I have several crons running at various times every day. Occasionally, one or another will get 'stuck' and its process will never die. This isn't consistent, but after a change in a function in a different file which several of the crons access, there's been a marked increase in the number of times. Not always to the same file, not always to the same time, and running the files manually works fine.
My questions:
If I modify this external file, the running cron should pick up the change, right? (Tried and it isn't working, so either it doesn't, or it didn't get to that point in my code, which brings me to my second question:)
How can I print a stack trace of the running cron in order to see where it gets stuck? Running on Linux, Centos version 7
Edit: pstack gives me main() - how can I get farther in than that?
#0 0x00007f710a129e0d in poll () from /lib64/libc.so.6
#1 0x00007f7102391ab9 in Curl_poll () from /lib64/libcurl.so.4
#2 0x00007f710238aa4d in curl_multi_wait () from /lib64/libcurl.so.4
#3 0x00007f7102383baf in curl_easy_perform () from /lib64/libcurl.so.4
#4 0x00007f71025c96f6 in zif_curl_exec () from /usr/lib64/php/modules/curl.so
#5 0x00007f71029e6a4d in xdebug_execute_internal (current_execute_data=0x7f710d8f14a0, return_value_used=1) at /var/tmp/xdebug/xdebug.c:1547
#6 0x00007f710dc61271 in zend_do_fcall_common_helper_SPEC ()
#7 0x00007f710dbde617 in execute ()
#8 0x00007f71029e5e3a in xdebug_execute (op_array=0x7f70fa316bc8) at /var/tmp/xdebug/xdebug.c:1435
#9 0x00007f710dc6190d in zend_do_fcall_common_helper_SPEC ()
#10 0x00007f710dbde617 in execute ()
#11 0x00007f71029e5e3a in xdebug_execute (op_array=0x7f710f89efb0) at /var/tmp/xdebug/xdebug.c:1435
#12 0x00007f710dc6190d in zend_do_fcall_common_helper_SPEC ()
#13 0x00007f710dbde617 in execute ()
#14 0x00007f71029e5e3a in xdebug_execute (op_array=0x7f710d921838) at /var/tmp/xdebug/xdebug.c:1435
#15 0x00007f710dbb727f in zend_execute_scripts ()
#16 0x00007f710db56656 in php_execute_script ()
#17 0x00007f710dc63548 in do_cli ()
#18 0x00007f710da1015e in main ()
Thanks for any help!
If any of the crons are leaving the file open then this might be the cause when a concurrent access attempt is made to the same file by different cron instances. You could write a small shell script to execute the code file preceded by something like
$ok = `lsof | grep -c <filename>`
if($ok != "0")
then sleep 5
fi

Categories