Repository navigation
zend_mm_heap corrupted when serializing/unserializing Enum #181
Description
Activity
earthiverse@ca6d866 made a test to reproduce it, seems more likely to fail when you include the Enum from another file
php-8.4-debug-nozts
TEST 145/145 [tests/issue181.phpt] ========DIFF======== Test 002- OK 002+ php: /tmp/php-8.4-debug-session-/src/php-8.4.16/Zend/zend_variables.c:133: zval_copy_ctor_func: Assertion `0' failed. 003+ Aborted (core dumped) 004+ 005+ Termsig=6 ========DONE======== FAIL Issue #181 (zend_mm_heap corrupted when serializing/unserializing Enum) [tests/issue181.phpt]php-8.4-nodebug-nozts
TEST 145/145 [tests/issue181.phpt] ========DIFF======== Test 002- OK 002+ zend_mm_heap corrupted 003+ Aborted (core dumped) 004+ 005+ Termsig=6 ========DONE======== FAIL Issue #181 (zend_mm_heap corrupted when serializing/unserializing Enum) [tests/issue181.phpt]
Edit: Tested a fix generated by AI earthiverse@671217f
It fixed the test case, but I have no idea what it's doing, and I don't want to burden anyone with slop, so I'm just editing my previous comment here.
@earthiverse could you please try and build #184. It could help with your issue as well, but I am not sure about that.
@earthiverse could you please try and build #184. It could help with your issue as well, but I am not sure about that.
Seems like it could be different issues...
Rebased the test I made on your master branch, but my test failed.
https://github.com/earthiverse/msgpack-php/actions/runs/24319495765Rebased your test on the fix that fixed my test, but your test failed.
https://github.com/earthiverse/msgpack-php/actions/runs/24319566957@earthiverse could you please try and build #184. It could help with your issue as well, but I am not sure about that.
Seems like it could be different issues...
Rebased the test I made on your master branch, but my test failed. https://github.com/earthiverse/msgpack-php/actions/runs/24319495765
Rebased your test on the fix that fixed my test, but your test failed. https://github.com/earthiverse/msgpack-php/actions/runs/24319566957
Would have been too easy, I guess. Thanks for testing though.
The your-tests-my-fix variant's test results look all over the place. I mean 8.1 and 8.4 are mostly satisfied while 8.2 and 8.3 are not. At least the php-8.4-debug-nozts and php-8.4-nodebug-zts tests seem to be fixed compared to the your-tests-no-fix variant. Sadly I can not see the test result details this way. So I will integrate your tests into my version and maybe I am able to extend my fix.
There you go. After hours of looking at the location valgrind points to during serialize, I came to the conclusion that the root cause is in unserialize as you already suggested. At least, I found a cleaner and simpler solution, which does exactly the same as your
GC_ADDREF(...)line, but hidden 😁
I also integrated your test and CI ran successfully.Reacted by Kent Rasmussen
This one works fine:
This one seems to fail with
zend_mm_heap corruptedafter runningUsing the object methods also fails:
Errors in both
and