Re: question about BUG_ON() and BUG()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 21 Mar 2008 12:35:48 -0700
ilya <jibberboosh@xxxxxxxxx> wrote:

> hello,
> 
> my first question is exactly when should this macro be used?
> 
> i want to use it in one of my functions to assert that the spin lock
> was acquired:
> 
> BUG_ON(!spin_is_locked(&dev->lock))
> 
> then i wanted to see what would happen if i do:
> 
> BUG_ON(spin_is_locked(&dev->lock))
> 
> ... after the lock was acquired; it freezes-up my system. how come?
> what does BUG() do that can lockup the kernel? should i even be using
> BUG_ON() in this kind of context?

BUG_ON() triggers BUG() when the condition is true.  You will only
want to test for things that need to be false.

BUG() will try to run an illegal instruction, in order to trap into
the error handler and kill the current process.  That in turn means
that the spinlock will never be unlocked, and your system is wedged.

It is used to kill the current process when a serious kernel error
occurs, and to help debug the problem.

http://kernelnewbies.org/FAQ/BUG

-- 
All rights reversed.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux