Use of "throw 0" as flow-control
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
New
|
Medium
|
Nicolae Brinza |
Bug Description
In loader_dtd.cpp for the loadXml() function, "throw 0" is used as "flow control" for the function. This is not an appropriate use of C++ exceptions. The very real danger is that the corresponding "catch (...)" swallows all other exceptions silently. This causes very hard-to-find bugs (as I recently had the misfortune of debugging).
The rule should be that if you ever write "catch (...)," the end of the catch block should ALWAYS rethrow the exception via "throw;". The catch block in this way only does some clean-up but makes no attempt to swallow the exception.
Please don't use "throw 0" with "catch (...)". Even using "goto" is better since it won't silently swallow exceptions.
Note that I have already cleaned up several other uses of "catch (...)" in the code (see bug #1103819). This bug is a related bug in that it's about the (mis)use of "catch (...)" but specifically a case I don't feel comfortable fixing myself. There is already a branch for all "catch (...)" fixes -- please use the bug-1103819 branch.
Related branches
- Chris Hillery: Needs Information
- Paul J. Lucas: Approve
-
Diff: 1283 lines (+397/-393)16 files modifiedsrc/api/xqueryimpl.cpp (+3/-17)
src/capi/cdynamic_context.cpp (+1/-4)
src/capi/cexpression.cpp (+1/-4)
src/capi/cimplementation.cpp (+1/-4)
src/capi/csequence.cpp (+1/-4)
src/capi/cstatic_context.cpp (+1/-4)
src/context/default_url_resolvers.cpp (+6/-0)
src/runtime/debug/debug_iterator_impl.cpp (+11/-18)
src/runtime/indexing/doc_indexer.cpp (+1/-3)
src/store/naive/loader_dtd.cpp (+118/-8)
src/store/naive/loader_fast.cpp (+51/-89)
src/store/naive/node_items.cpp (+13/-27)
src/store/naive/node_updates.cpp (+179/-186)
src/store/naive/pul_primitives.cpp (+5/-1)
src/store/naive/store.cpp (+2/-3)
src/types/schema/schema.cpp (+3/-21)
Changed in zorba: | |
milestone: | 2.9 → 3.0 |
Changed in zorba: | |
milestone: | 3.0 → none |