Gearman Server and Client Libraries

segfault in in gearman_client_run_tasks()

Reported by Sven Nierlein on 2012-03-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Low
Brian Aker

Bug Description

When i run gearman_client_run_tasks() i get a segfault in client()
gdb backtrace is:

Program received signal SIGSEGV, Segmentation fault.
0x080ae180 in client ()
(gdb)
(gdb) bt
#0 0x080ae180 in client ()
#1 0xb7c9742c in gearman_universal_set_error (universal=..., rc=GEARMAN_NO_SERVERS, function=0xb7ca26e0 "_client_run_task", position=0xb7ca2611 "libgearman/run.cc:54",
    format=0xb7ca2600 "no servers added") at libgearman/error.cc:120
#2 0xb7c9b322 in _client_run_task (client=0x80ae060, task=0x80f7090) at libgearman/run.cc:54
#3 0xb7c93ec3 in _client_run_tasks (client=0x80ae060) at libgearman/client.cc:1238
#4 0xb7c94577 in gearman_client_run_tasks (client=0x80ae060) at libgearman/client.cc:1472

I tried stable 0.28 and latest trunk. The error is the same. It had worked with v0.25, but i did not try 0.26 and 0.27 yet.

Thanks

Brian Aker (brianaker) on 2012-03-11
Changed in gearmand:
assignee: nobody → Brian Aker (brianaker)
Brian Aker (brianaker) wrote :

Do you have an example of your code? It looks like client has never been set in the task object.

Sven Nierlein (sven-nierlein) wrote :

The error occurs in one of my test cases:
https://github.com/sni/mod_gearman/blob/master/t/02-full.c#L375

First i call
gearman_client_add_task_background(client, ...)
and then
gearman_client_run_tasks( client )

The client should be ok and should have servers set.

Brian Aker (brianaker) wrote :

Pull lp:gearmand and see what error you get. The only way I believe this bug could happen would be because of any issue your code (basically a bad task).

Changed in gearmand:
milestone: none → 0.29
status: New → Triaged
importance: Undecided → Low
status: Triaged → Fix Committed
Sven Nierlein (sven-nierlein) wrote :

Tree is up to date at revision 502.

The error is the same but the line numbers have changed.

#0 0x080ab120 in client ()
#1 0xb7fcc9e4 in gearman_universal_set_error (universal=..., rc=GEARMAN_NO_SERVERS, function=0xb7fd837c "_client_run_task",
    position=0xb7fd82be "libgearman/run.cc:64", format=0xb7fd82ad "no servers added") at libgearman/error.cc:128
#2 0xb7fd099e in _client_run_task (task=0x80d9830) at libgearman/run.cc:64
#3 0xb7fc934c in _client_run_tasks (client=0x80ab000) at libgearman/client.cc:1252
#4 0xb7fc9ab4 in gearman_client_run_tasks (client=0x80ab000) at libgearman/client.cc:1488

In addition to the segfault, i get lots of messages like this:

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", at libgearman/packet.cc:257

the only free i use, is the gearman_client_task_free_all(client) after gearman_client_run_tasks(). But i don't think thats the point here, because the segfault is already before the free.

Brian Aker (brianaker) wrote :

I think I found out what was happening here. After a task has been deleted it needs to check to see if it is the active task, and if that is the case set the client's active to null as well.

Changed in gearmand:
status: Fix Committed → In Progress
Brian Aker (brianaker) on 2012-12-13
Changed in gearmand:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers