Try/catch for modules?
Ruben Safir
ruben at mrbrklyn.com
Fri Oct 18 13:02:10 EDT 2019
On Fri, Oct 18, 2019 at 01:11:54PM -0300, Martin Galvan wrote:
> El vie., 18 oct. 2019 a las 13:05, Bernd Petrovitsch
> (<bernd at petrovitsch.priv.at>) escribió:
> > You actually want speed in the kernel and not necessarily extra effort
> > for "try" and "catch" which is - sooner or later - never really used.
> > And the "safety net" reduces the motivation to actually fix pointer bugs ....
>
> I don't think I was clear. My intent is that if a pointer bug isn't
> fixed, my module will fail gracefully and go through the catch block
> instead of panicking the whole system. I don't see how this would stop
> me from fixing the bug itself; if anything, it could even help me
> debug it.
>
I don't think you really understand what is going on here. On the
kernel level you would never wrap up a process in another process in
order to catch a mistake, and then do error correction. That method of
programming is not appropriate for kernel level code where you are
running everything on the hardware.
You can test for a condition before you run the code, and use GOTO if
you want, but you are not doing a Java like Catch and Throw.
> > A ioctl-handler runs in the context/on behalf/... of a process
> > (read: a user-space process/thread has called a syscall).
>
> Yes.
>
> > And there may be other code in your module which doesn't run
> > on behalf of a process/thread, e.g. triggered by a timer, hardware
> > IRQ, ...
>
> That's an interesting point. Yes, my die_notifier will run in
> exception context, but current->pid will still match that of the
> process which triggered the exception. I don't know if this happens by
> definition or it's just a coincidence, but it seems to work.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013
More information about the Kernelnewbies
mailing list