Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet that is being freed has not been allocated, most likely this is due to freeing a gearman_task_st or other object twice #347

Closed
easterism opened this issue Sep 15, 2022 · 4 comments
Labels

Comments

@easterism
Copy link

I've got error and looks it related to #68 (comment)

libgearman/packet.cc:253 Assertion "packet->universal" failed for function "gearman_packet_free" likely for "Packet that is being freed has not been allocated, most likely this is do to freeing a gearman_task_st or other object twice"

Begin stack trace, frames found: 34
?0  0x7efcd4cf7f0f in /usr/local/lib/libgearman.so.8(+0x7f0f) [0x7efcd4cf7f0f]
?1  0x7efcd4d028e0 in /usr/local/lib/libgearman.so.8(+0x128e0) [0x7efcd4d028e0]
?2  0x7efcd4cfbf8d in /usr/local/lib/libgearman.so.8(+0xbf8d) [0x7efcd4cfbf8d]
?3  0x7efcd4cfbfed in /usr/local/lib/libgearman.so.8(+0xbfed) [0x7efcd4cfbfed]
?4  0x7efcd4d058a0 in /usr/local/lib/libgearman.so.8(+0x158a0) [0x7efcd4d058a0]
?5  0x7efcd4d058dd in /usr/local/lib/libgearman.so.8(+0x158dd) [0x7efcd4d058dd]
#6  0x7efcd4d08898 in gearman_worker_free at /usr/local/lib/libgearman.so.8
#7  0x7efcd4d2f831 in zim_GearmanWorker___destruct at /usr/lib/php/20200930/gearman.so
?8  0x7efcd7065499 in /usr/lib/php/20200930/xdebug.so(+0x16499) [0x7efcd7065499]
#9  0x5612e5d09452 in zend_call_function at php8.0
#10  0x5612e5d09705 in zend_call_known_function at php8.0
#11  0x5612e5d99a84 in zend_objects_destroy_object at php8.0
#12  0x5612e5d9e474 in zend_objects_store_del at php8.0
#13  0x5612e5d7dc7f in execute_ex at php8.0
?14  0x7efcd7064e3a in /usr/lib/php/20200930/xdebug.so(+0x15e3a) [0x7efcd7064e3a]
?15  0x5612e5b6007c in php8.0(+0x10a07c) [0x5612e5b6007c]
#16  0x5612e5d7fd89 in execute_ex at php8.0
?17  0x7efcd7064e3a in /usr/lib/php/20200930/xdebug.so(+0x15e3a) [0x7efcd7064e3a]
?18  0x5612e5b6007c in php8.0(+0x10a07c) [0x5612e5b6007c]
#19  0x5612e5d7fd89 in execute_ex at php8.0
?20  0x7efcd7064e3a in /usr/lib/php/20200930/xdebug.so(+0x15e3a) [0x7efcd7064e3a]
?21  0x5612e5b6007c in php8.0(+0x10a07c) [0x5612e5b6007c]
#22  0x5612e5d7fd89 in execute_ex at php8.0
?23  0x7efcd7064e3a in /usr/lib/php/20200930/xdebug.so(+0x15e3a) [0x7efcd7064e3a]
?24  0x5612e5b6007c in php8.0(+0x10a07c) [0x5612e5b6007c]
#25  0x5612e5d7fd89 in execute_ex at php8.0
?26  0x7efcd7064e3a in /usr/lib/php/20200930/xdebug.so(+0x15e3a) [0x7efcd7064e3a]
#27  0x5612e5d800fc in zend_execute at php8.0
#28  0x5612e5d16b6d in zend_execute_scripts at php8.0
#29  0x5612e5cb361b in php_execute_script at php8.0
?30  0x5612e5da5dce in php8.0(+0x34fdce) [0x5612e5da5dce]
?31  0x5612e5b69aeb in php8.0(+0x113aeb) [0x5612e5b69aeb]
#32  0x7efcd960f09b in __libc_start_main at /lib/x86_64-linux-gnu/libc.so.6
#33  0x5612e5b69c4a in _start at php8.0

Could you explain please, what happened

@esabol
Copy link
Member

esabol commented Sep 16, 2022

Does this happen all the time or just occasionally?

The packet was freed twice, as the assertion says, "most likely this is do [sic] to freeing a gearman_task_st or other object twice." I want to say that this problem is due to a bug in the PHP extension, but I don't know for certain.

Are you using the latest version from https://github.com/php/pecl-networking-gearman ? If so, you might want to open an issue there, especially if you can boil it down to something reproducible. Unfortunately, the PHP extension is not very actively maintained, I think, so I'm not sure how much help you might get there.

If you recompile libgearman.so with GEARMAN_PACKET_TRACE defined, it will output a lot more information about the packet to stderr. That might be helpful.

If you can't fix the PHP extension (assuming that's the problem), you could edit libgearman/packet.cc and comment out the assertion on lines 252-253 and change line 255 to read

  if (gearman_is_allocated(packet) || !(packet->universal))

(or maybe flip that conditional around). But that makes me feel dirty just thinking about it and you should only do that as a last resort. The fix should really be made in the PHP extension, I think.

@easterism
Copy link
Author

easterism commented Sep 16, 2022

Does this happen all the time or just occasionally?

just occasionally, i catch this after i checked gearadmin --status and it stuck (like this #68 (comment))

I use php-gearman Debian package. Looks like its lastest version of pecl-networking-gearman

P.S. new issue php/pecl-networking-gearman#17 (comment)

@esabol esabol changed the title Packet that is being freed has not been allocated, most likely this is do to freeing a gearman_task_st or other object twice Packet that is being freed has not been allocated, most likely this is due to freeing a gearman_task_st or other object twice Sep 18, 2022
@esabol
Copy link
Member

esabol commented Nov 13, 2022

A PHP extension developer posted their analysis and suggested a potential fix to the PHP extension code here:

php/pecl-networking-gearman#12 (comment)

They agreed that the problem is likely in the PHP extension, so I'm closing this issue.

@SpamapS
Copy link
Member

SpamapS commented Nov 13, 2022

Nice work @esabol !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants