gearman / gearmand

http://gearman.org/
Other
737 stars 138 forks source link

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 closed 1 year ago

easterism commented 2 years ago

I've got error and looks it related to https://github.com/gearman/gearmand/issues/68#issuecomment-1245583214

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 commented 2 years ago

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 commented 2 years ago

Does this happen all the time or just occasionally?

just occasionally, i catch this after i checked gearadmin --status and it stuck (like this https://github.com/gearman/gearmand/issues/68#issuecomment-1245583214)

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

P.S. new issue https://github.com/php/pecl-networking-gearman/issues/17#issue-1375775689

esabol commented 1 year ago

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

https://github.com/php/pecl-networking-gearman/issues/12#issuecomment-1280379848

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

SpamapS commented 1 year ago

Nice work @esabol !