Vancouver: catch exception during module loading

Catch any kind of exception we get from the rm_session during module
loading. Panic if modules can't be processed (too big images and so on)
This commit is contained in:
Alexander Boettcher 2012-09-17 14:01:11 +02:00 committed by Norman Feske
parent 7bd0ed7c44
commit 8af582fac2
2 changed files with 10 additions and 2 deletions

View File

@ -37,6 +37,7 @@ class Boot_module_provider
* Exception class * Exception class
*/ */
class Destination_buffer_too_small { }; class Destination_buffer_too_small { };
class Module_loading_failed { };
/** /**
* Constructor * Constructor
@ -107,10 +108,13 @@ class Boot_module_provider
PWRN("XML node %d in multiboot node has unexpected type", PWRN("XML node %d in multiboot node has unexpected type",
module_index); module_index);
return 0; throw Module_loading_failed();
} }
catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_sub_node) { }
catch (Xml_node::Nonexistent_attribute) { } catch (Xml_node::Nonexistent_attribute) { }
catch (...) {
throw Module_loading_failed();
}
/* /*
* We should get here only if there are XML parsing errors * We should get here only if there are XML parsing errors

View File

@ -847,7 +847,11 @@ class Machine : public StaticReceiver<Machine>
try { try {
data_len = _boot_modules.data(index, data_dst, dst_len); data_len = _boot_modules.data(index, data_dst, dst_len);
} catch (Boot_module_provider::Destination_buffer_too_small) { } catch (Boot_module_provider::Destination_buffer_too_small) {
Logging::printf("could not load module, destination buffer too small\n"); Logging::panic("could not load module, destination buffer too small\n");
return false;
} catch (Boot_module_provider::Module_loading_failed) {
Logging::panic("could not load module %d,"
" unknown reason\n", index);
return false; return false;
} }