Skip to content

Commit

Permalink
core/lock: Stop drop_my_locks() from always causing abort
Browse files Browse the repository at this point in the history
The loop in drop_my_locks() looks like this:

	while((l = list_pop(&this_cpu()->locks_held, struct lock, list)) != NULL) {
		if (warn)
			prlog(PR_ERR, "  %s\n", l->owner);
		unlock(l);
	}

Both list_pop() and unlock() call list_del(). This means that on the
last iteration of the loop, the list will be empty when we get to
unlock_check(), causing this:

  LOCK ERROR: Releasing lock we don't hold depth @0x30493d20 (state: 0x0000000000000001)
  [13836.000173140,0] Aborting!
  CPU 0000 Backtrace:
   S: 0000000031c03930 R: 000000003001d840   ._abort+0x60
   S: 0000000031c039c0 R: 000000003001a0c4   .lock_error+0x64
   S: 0000000031c03a50 R: 0000000030019c70   .unlock+0x54
   S: 0000000031c03af0 R: 000000003001a040   .drop_my_locks+0xf4

To fix this, change list_pop() to list_top().

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
rarbab authored and stewartsmith committed Feb 4, 2019
1 parent 87517c8 commit 9ef153f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void drop_my_locks(bool warn)
struct lock *l;

disable_fast_reboot("Lock corruption");
while((l = list_pop(&this_cpu()->locks_held, struct lock, list)) != NULL) {
while((l = list_top(&this_cpu()->locks_held, struct lock, list)) != NULL) {
if (warn)
prlog(PR_ERR, " %s\n", l->owner);
unlock(l);
Expand Down

0 comments on commit 9ef153f

Please sign in to comment.