How to catch unhandled exceptions ?
BogDan
bog_dan_ro at yahoo.com
Mon Jun 3 12:46:03 CEST 2013
Hi,
> [..]
>> So far so good! This is exactly what I want to do, to have a way to be
> notified
>> by the kernel about any exception of a thread. Now my problem is that I
>> get no notification when something bad happens (e.g. division by 0 or a
>> page fault), is there any example where I can look to see how to use
>> thread control + exc_handler and co ? I don't think I really know what
> to
>> pass to exc_handler method, I tried to pass a L4::Server_Object::obj_cap()
>> object but nothing happened ...
>
> The page fault handler and the exception handler are Fiasco.OC threads.
> Hence, you pass thread capabilities to those calls. Page faults go to
> the PF handler , all other exceptions end up in the exception handler
> thread.
>
> In the thread you would then do something like
>
> while (1) {
> msg = l4_ipc_receive();
> inject_exception();
> }
>
> In inject_exception() you can use the Thread::ex_regs system call, which
> allows you to modify the IP/SP of a thread.
>
Still no joy :(, here http://paste.kde.org/757352/ what I'm using ... I still
don't understand what I'm doing so wrong there ... Also I don't know
how to get the caller thread l4_cap_idx_t struct from l4_utcb_t.
> [..]
>>> Also, C++ exceptions need to be caught in the thread that raised the
>>> exception, otherwise the exceptions causes a call to std::terminate,
>>> wich will abort your application. Hence, you'd need try/catch
> statements
>>> for all potential hardware exceptions around all your threads'
> code.
>>>
>>
>> Of course you need to add try/catch statements :) The beauty is that if
>> you'll do it, you'll have a chance to survive to save your data, if
> not,
>> then, as you said, std::terminate will be called and you get the same
>> effect.
>
> There may be libraries (e.g., libc_be_signal) that spawn their own
> threads and where you do not have control over potential try/catch
> statements in their code. But that might not be an issue for you.
>
If I set the handler to main thread, then all the thread will have the
same handler set, right ?
Thanks.
Cheers,
BogDan.
More information about the l4-hackers
mailing list