From 8af582fac2baa5a9d9cd3062a0b24c5505dc5602 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 17 Sep 2012 14:01:11 +0200 Subject: [PATCH] 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) --- ports/src/vancouver/boot_module_provider.h | 6 +++++- ports/src/vancouver/main.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ports/src/vancouver/boot_module_provider.h b/ports/src/vancouver/boot_module_provider.h index 07ea3ddb8..477ab42d1 100644 --- a/ports/src/vancouver/boot_module_provider.h +++ b/ports/src/vancouver/boot_module_provider.h @@ -37,6 +37,7 @@ class Boot_module_provider * Exception class */ class Destination_buffer_too_small { }; + class Module_loading_failed { }; /** * Constructor @@ -107,10 +108,13 @@ class Boot_module_provider PWRN("XML node %d in multiboot node has unexpected type", module_index); - return 0; + throw Module_loading_failed(); } catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_attribute) { } + catch (...) { + throw Module_loading_failed(); + } /* * We should get here only if there are XML parsing errors diff --git a/ports/src/vancouver/main.cc b/ports/src/vancouver/main.cc index 8ec8a0f2e..9caf757f1 100644 --- a/ports/src/vancouver/main.cc +++ b/ports/src/vancouver/main.cc @@ -847,7 +847,11 @@ class Machine : public StaticReceiver try { data_len = _boot_modules.data(index, data_dst, dst_len); } 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; }