#1099672 php8.4: test are crashing with `zend_mm_heap corrupted`

#1099672#5
Date:
2025-03-06 15:05:23 UTC
From:
To:
Dear Maintainer,

While trying to update php-league-csv from 9.20.1 to 9.22 I faced an issue on
trixie runnning PHP 8.4.4

The build job, that invokes phpunit for the tests fails this way.

https://salsa.debian.org/php-team/pear/php-league-csv/-/jobs/7206384

Running the same tests with phpunit through composer leads to the same issue.
Running the same tests with phpunit through composer but on bookworm, that
runs 8.2, doesn't fail.
Upstream runs the tests in a github actions job on PHP 8.4.4 without issue
either.

So issue doesn't seem to be related to phpunit, and maybe it is related to the
php version shipped in debian.

Output:
-------------------------
phpunit --exclude-group network --no-coverage
PHPUnit 11.5.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.4
Configuration: /mnt/packages/git_repos/dpkg/php-league-csv/phpunit.xml

...............................................................  63 / 678 (
9%)
............................................................... 126 / 678 (
18%)
..........DDDDD................................................ 189 / 678 (
27%)
....................................DDDDDDDDDDD.............zend_mm_heap
corrupted
make[1]: *** [debian/rules:36: override_dh_auto_test] Aborted (core dumped)



When invoking with USE_ZEND_ALLOC=0, reported error is slightly different:
-------------------------
phpunit --exclude-group network --no-coverage
PHPUnit 11.5.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.4
Configuration: /mnt/packages/git_repos/dpkg/php-league-csv/phpunit.xml

...............................................................  63 / 678 (
9%)
............................................................... 126 / 678 (
18%)
..........DDDDD................................................ 189 / 678 (
27%)
.................malloc(): unaligned fastbin chunk detected 3

#1099672#10
Date:
2025-03-06 15:20:43 UTC
From:
To:
I found that if I invoke phpunit with `XDEBUG_MODE=coverage` there is no
failure.

#1099672#15
Date:
2025-03-06 17:17:48 UTC
From:
To:
I found that if I uninstall php8.4-xdebug there is no failure.
#1099672#20
Date:
2025-03-06 17:22:42 UTC
From:
To:

#1099672#27
Date:
2025-03-07 07:06:58 UTC
From:
To:
See valgrind log attached & below.

==1387732== Memcheck, a memory error detector
==1387732== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==1387732== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==1387732== Command: /usr/bin/phpunit --exclude-group network --no-coverage
==1387732==
PHPUnit 11.5.8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.4
Configuration: /mnt/packages/git_repos/dpkg/php-league-csv/phpunit.xml

...............................................................  63 / 678 (
9%)
............................................................... 126 / 678 (
18%)
..........DDDDD................................................ 189 / 678 (
27%)
....................................DDDDDDDDDDD.............zend_mm_heap
corrupted
==1387732==
==1387732== Process terminating with default action of signal 6 (SIGABRT)
==1387732==    at 0x537DDCC: __pthread_kill_implementation (pthread_kill.c:44)
==1387732==    by 0x5329D01: raise (raise.c:26)
==1387732==    by 0x53124EF: abort (abort.c:79)
==1387732==    by 0x21E1BC: zend_mm_panic.constprop.0 (zend_alloc.c:398)
==1387732==    by 0x21E3FB: zend_mm_get_next_free_slot (zend_alloc.c:1326)
==1387732==    by 0x21E3FB: zend_mm_alloc_small (zend_alloc.c:1410)
==1387732==    by 0x21E3FB: zend_mm_alloc_heap (zend_alloc.c:1488)
==1387732==    by 0x21E3FB: _emalloc.cold (zend_alloc.c:2740)
==1387732==    by 0x502EDA: zend_string_alloc (zend_string.h:176)
==1387732==    by 0x502EDA: zend_string_init (zend_string.h:198)
==1387732==    by 0x502EDA: lex_scan (zend_language_scanner.c:2038)
==1387732==    by 0x45858B: zendlex (zend_compile.c:2040)
==1387732==    by 0x4F8A1E: zendparse (zend_language_parser.c:5011)
==1387732==    by 0x4FBE51: zend_compile (zend_language_scanner.c:601)
==1387732==    by 0x4FD5C6: compile_file (zend_language_scanner.c:655)
==1387732==    by 0xA04E557: phar_compile_file (phar.c:3312)
==1387732==    by 0x8016EAD: xdebug_compile_file (base.c:94)
==1387732==
==1387732== HEAP SUMMARY:
==1387732==     in use at exit: 5,382,219 bytes in 42,273 blocks
==1387732==   total heap usage: 1,026,852 allocs, 984,579 frees, 71,419,640
bytes allocated
==1387732==
==1387732== LEAK SUMMARY:
==1387732==    definitely lost: 33,792 bytes in 1,056 blocks
==1387732==    indirectly lost: 40 bytes in 1 blocks
==1387732==      possibly lost: 3,392,974 bytes in 23,194 blocks
==1387732==    still reachable: 1,955,413 bytes in 18,022 blocks
==1387732==         suppressed: 0 bytes in 0 blocks
==1387732== Rerun with --leak-check=full to see details of leaked memory
==1387732==
==1387732== For lists of detected and suppressed errors, rerun with: -s
==1387732== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

#1099672#32
Date:
2025-03-07 07:14:44 UTC
From:
To:
Thanks for your reply. But is this xdebug issue or php issue?


Le vendredi 7 mars 2025, 08:11:35 CET Ondřej Surý a écrit :

#1099672#37
Date:
2025-03-07 07:20:15 UTC
From:
To:
Xdebug issue. Well, at least I would start reporting this to xdebug and Derick will handle this if this is PHP issue anyway.
--
Ondřej Surý (He/Him)

#1099672#42
Date:
2025-03-07 07:11:35 UTC
From:
To:
This would be best reported to xdebug upstream. This is the latest upstream
version, so this needs to be fixed upstream.

Ondrej
--
Ondřej Surý (He/Him)
ondrej@sury.org

#1099672#47
Date:
2025-03-07 12:50:03 UTC
From:
To:
Le vendredi 7 mars 2025, 13:42:12 CET Fab Stz a écrit :

Actually not, it worked on bookworm because on bookworm I have
xdebug.mode => debug,coverage => debug,coverage
While on trixie I have
xdebug.mode => develop => develop

But if I remove "coverage" from xdebug.mode on bookworm, it fails as well.

#1099672#52
Date:
2025-10-29 05:46:49 UTC
From:
To:
Hello,

The bug has been fixed upstream in 3.4.6 , could you please update the version in Debian? Latest is 3.4.7 at the moment

Regards
Fab

#1099672#61
Date:
2026-01-01 08:34:57 UTC
From:
To:
Hi,

Please update xdebug in Debian. This bug has fixed upstream for a few months and was causing FTBFS in php-league-csv which has a workaround because of it and is apparently causing other issues now.

Regards
Fab

#1099672#66
Date:
2026-01-01 11:47:44 UTC
From:
To:
Dear Ondrej,

Apparently the new issue in php-league-csv is now caused by php 8.4.16

See
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1124191
https://github.com/thephpleague/csv/issues/572

Nevertheless, update of xdebug would be still very useful and permit to remove a workaround specific to debian in php-league-csv

Regards