[NSWI004] How to cause segmentation fault.
Petr Tuma
petr.tuma at d3s.mff.cuni.cz
Fri Oct 30 19:12:29 CET 2020
Hi,
I guess your point is how to do an equivalent of an `assert` statement (that is, announce a fatal error and stop the execution) ? For that, there already is an `assert` macro in `debug.h` ... or did you have something else in mind ?
Petr
On 30/10/2020 18:55, Jura Pelc wrote:
> Hello,
>
> I am working on the implementation of free and I come across a conflict between me as a C# programer and kernel C code.
> ```c
> if((uintptr_t)ptr < heap_begin || (uintptr_t)ptr > heap_end)
> {
> //TODO: segmentation fault
> return;
> }
> ```
> I want to safely determine that the user is dum and trying to free some unknown memory.
> For this, I can see some kind of range check for free and "throwing" segmentation fault as interop.
> I was thinking about https://www.tutorialspoint.com/c_standard_library/c_function_raise.htm <https://www.tutorialspoint.com/c_standard_library/c_function_raise.htm>, but I did not found this is the kernel.
>
> So my question is, how to raise segmentation fault during free safely?
>
> --
>
> S pozdravem Jiří Pelc
> Matematicko-fyzikální fakulta
> Univerzita Karlova
>
> _______________________________________________
> NSWI004 mailing list
> NSWI004 at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/nswi004
>
More information about the NSWI004
mailing list