IchHabRecht / mask_export

Export your mask elements as extension
GNU General Public License v2.0
45 stars 27 forks source link

Strange segmentation fault (SIGSEGV) inside DDEV Context (502) #206

Open Xippo opened 1 year ago

Xippo commented 1 year ago

Hi dear hard working developers,

i have a quite strange issue, when i try the actual mask_export inside a ddev project.

When we try to write or download the generated extension, we get a 502 Error.(the same when we try to use apache-fpm)

Inside the webserver logs we found:

[Mon Feb 27 12:19:52.731654 2023] [proxy_fcgi:error] [pid 2158] [client 172.18.0.6:49250] AH01067: Failed to read FastCGI header, referer: https://domain.ddev.site/typo3/module/tools/MaskExportMaskExport?tx_maskexport_tools_maskexportmaskexport%5Baction%5D=list&tx_maskexport_tools_maskexportmaskexport%5Bcontroller%5D=Export

[Mon Feb 27 12:19:52.731706 2023] [proxy_fcgi:error] [pid 2158] (104)Connection reset by peer: [client 172.18.0.6:49250] AH01075: Error dispatching request to : , referer: https://domain.ddev.site/typo3/module/tools/MaskExportMaskExport?tx_maskexport_tools_maskexportmaskexport%5Baction%5D=list&tx_maskexport_tools_maskexportmaskexport%5Bcontroller%5D=Export

[27-Feb-2023 12:19:52] WARNING: [pool www] child 2497 exited on signal 11 (SIGSEGV) after 191.261676 seconds from start
[27-Feb-2023 12:19:52] NOTICE: [pool www] child 2531 started

i have tested as well the same versions on a live webserver without a problem.

i have done a debug session for a couple of hours and i found out that the origin of the problem is this part inside the ExportController

 // Find all used fields in elements and foreign tables
        $columns = [];
        $closure = null;
        $closure = static function ($value) use ($aggregatedConfiguration, &$columns, &$closure) {
            foreach (($value['columns'] ?? []) as $field) {
                $columns[] = $field;
                if (!empty($aggregatedConfiguration[$field]['tca'])) {
                    array_map($closure, [['columns' => array_keys($aggregatedConfiguration[$field]['tca'])]]);

                }
            }
        };

        array_map($closure, $aggregatedConfiguration['tt_content']['elements']);

when the recursion is called (it happens when the mask element has sections) the process dies.

i could fix the problem changing

 array_map($closure, [['columns' => array_keys($aggregatedConfiguration[$field]['tca'])]]);

to

 array_map($closure, ['columns' => array_keys($aggregatedConfiguration[$field]['tca'])]);

i tried this because i didn't understand why the parameter is given as array inside array, for me the body of the functions seems to work with a one level array only.

Specs: TYPO3: 11.5.24 DDEV: 1.17.x and 1.21.4 Mask: 7.2.15 Mask_export: 4.0.2 Inside DDEV i tried PHP Version 7.4, 8.1 and 8.2 As webserver we tried both apache-fpm and nginx-fpm

i know this is an annoying bug for you(quite a edge case and deep inside a complex stack like ddev/docker etc.) and maybe a bit out of context of the extension self. So feel free to close the issue, but maybe some one will find the information helpfull and maybe you could explain me whats behind the array in array thing :) .

Thank you for your time.

chrirauch commented 1 year ago

Had the same issue. apache/php segfaulting in the $closure function, but I'm running a pretty standard apache/mysql setup..

just changing the line in the closure function removes the segfault error for me, but results in other errors, especially regarding the ext_tables.sql file generation.

For me the problem was with 1 specific content element which i did not need anymore. If i find the time and manage to reproduce it, I will try to create a small example mask.json file