Re: Compiling C++ modules

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

 



Denis Vlasenko wrote:
Additionally, C++ guarantees that if an exception is thrown after spin_lock() is called, then the spin_unlock() will also be called. That's an interesting mechanism by itself.

Life gets even more interesting when you hit another exception
inside destructor(s) being executed due to first one.
Say, spin_unlock() discovers that lock is already unlocked
and does "throw BUG_double_unlock".

You're not allowed to throw exceptions from inside the stack unwinding caused by another exception, terminate() gets called in this case. In most cases this isn't too hard to avoid, you just have to ensure that exceptions don't get thrown out of destructors. Your example isn't very good, why would you throw an exception in that case? The caller isn't going to be able to do anything useful with it since it's because of a coding bug, some kind of assert or BUG() would be more logical.

--
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux