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

tasks coverities #10401

Closed
radare opened this issue Jun 19, 2018 · 8 comments
Closed

tasks coverities #10401

radare opened this issue Jun 19, 2018 · 8 comments
Labels
Milestone

Comments

@radare
Copy link
Collaborator

radare commented Jun 19, 2018

*** CID 1393487:  Concurrent data access violations  (MISSING_LOCK)
/libr/core/task.c: 294 in r_core_task_sync_begin()
288     /* begin running stuff synchronously on the main task */
289     R_API void r_core_task_sync_begin(RCore *core) {
290     	RCoreTask *task = core->main_task;
291     	task->thread = NULL;
292     	task->cmd = NULL;
293     	task->cmd_log = false;
   CID 1393487:  Concurrent data access violations  (MISSING_LOCK)
   Accessing "task->state" without holding lock "r_th_lock_t.lock". Elsewhere, "r_core_task_t.state" is accessed with "r_th_lock_t.lock" held 2 out of 4 times (2 of these accesses strongly imply that it is necessary).
294     	task->state = R_CORE_TASK_STATE_BEFORE_START;
295     	task_wakeup (task);
296     }
297     
298     /* end running stuff synchronously, initially started with r_core_task_sync_begin() */
299     R_API void r_core_task_sync_end(RCore *core) {

** CID 1393486:  Program hangs  (LOCK)
/libr/core/task.c: 229 in task_wakeup()


________________________________________________________________________________________________________
*** CID 1393486:  Program hangs  (LOCK)
/libr/core/task.c: 229 in task_wakeup()
223     			// and has to be dumped.
224     			core->main_task->cons = r_cons_dump ();
225     		}
226     		r_cons_load (current->cons);
227     		current->cons = NULL;
228     	}
   CID 1393486:  Program hangs  (LOCK)
   Returning without unlocking "current->dispatch_lock->lock".
229     }
230     
231     R_API void r_core_task_continue(RCoreTask *t) {
232     	r_core_task_schedule (t, R_CORE_TASK_STATE_RUNNING);
233     }
234     

** CID 1393485:  Incorrect expression  (CONSTANT_EXPRESSION_RESULT)
/libr/core/task.c: 104 in r_core_task_new()


________________________________________________________________________________________________________
*** CID 1393485:  Incorrect expression  (CONSTANT_EXPRESSION_RESULT)
/libr/core/task.c: 104 in r_core_task_new()
98     	task->thread = NULL;
99     	task->cmd = cmd ? strdup (cmd) : NULL;
100     	task->cmd_log = false;
101     	task->res = NULL;
102     	task->dispatch_cond = r_th_cond_new ();
103     	task->dispatch_lock = r_th_lock_new (false);
   CID 1393485:  Incorrect expression  (CONSTANT_EXPRESSION_RESULT)
   The expression "!task->dispatch_cond || !task->dispatch_cond" does not accomplish anything because it evaluates to either of its identical operands, "!task->dispatch_cond".
104     	if (!task->dispatch_cond || !task->dispatch_cond) {
105     		goto hell;
106     	}
107     
108     	task->id = core->task_id_next++;
109     	task->state = R_CORE_TASK_STATE_BEFORE_START;
@radare radare added this to the 2.7.0 milestone Jun 19, 2018
@radare
Copy link
Collaborator Author

radare commented Jun 19, 2018

cc @thestr4ng3r

@thestr4ng3r
Copy link
Contributor

Noted. I'll take a look at it.

thestr4ng3r added a commit to thestr4ng3r/radare2 that referenced this issue Jun 19, 2018
@thestr4ng3r
Copy link
Contributor

The second one about current->dispatch_lock is explicitly done like this since that is the lock for the condition variable, which must stay locked there.
Is there a way to explicitly ignore errors in coverity?

@radare
Copy link
Collaborator Author

radare commented Jun 20, 2018 via email

@XVilka XVilka added the RCore label Jun 21, 2018
@XVilka
Copy link
Contributor

XVilka commented Jun 21, 2018

@thestr4ng3r checkout also this please:

gdb$ run -d /bin/ls
Starting program: /usr/bin/r2 -d /bin/ls
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Process with PID 24129 started...
= attach 24129 24129
bin.baddr 0x555555554000
Using 0x555555554000
asm.bits 64
[0x7ffff7dd9000]> db main
[0x7ffff7dd9000]> dc
hit breakpoint at: 555555557ac0
[0x555555557ac0]> dmh
Warning: glibc library with symbol main_arena could not be found. Is libc6-dbg installed?

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4152145 in r_list_pop_head () from /usr/lib64/libr_util.so
gdb$ bt
#0  0x00007ffff4152145 in r_list_pop_head () from /usr/lib64/libr_util.so
#1  0x00007ffff7b5fa9f in r_core_task_schedule () from /usr/lib64/libr_core.so
#2  0x00007ffff73de679 in r_cons_is_breaked () from /usr/lib64/libr_cons.so
#3  0x00007ffff7b07297 in ?? () from /usr/lib64/libr_core.so
#4  0x00007ffff7b37d7d in r_cmd_call () from /usr/lib64/libr_core.so
#5  0x00007ffff7b0541f in ?? () from /usr/lib64/libr_core.so
#6  0x00007ffff7ac69ba in ?? () from /usr/lib64/libr_core.so
#7  0x00007ffff7ac6ec7 in r_core_cmd () from /usr/lib64/libr_core.so
#8  0x00007ffff7aa517d in r_core_prompt () from /usr/lib64/libr_core.so
#9  0x0000555555558ad9 in ?? ()
#10 0x00007ffff3b3f9f7 in __libc_start_main () from /lib64/libc.so.6
#11 0x0000555555559eca in ?? ()
gdb$ 

@thestr4ng3r
Copy link
Contributor

Seems to be this issue: #10387
If cleaning and re-compiling does not help, maybe reopen that one.

@XVilka
Copy link
Contributor

XVilka commented Jun 21, 2018

@thestr4ng3r cleaned up everything, took a shower and vacuumed floor - crash is here still.

@thestr4ng3r
Copy link
Contributor

Crash is fixed, I think this issue can be closed.

@Maijin Maijin closed this as completed Jul 3, 2018
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

4 participants