[NSWI004] dprintk makes my code stable
Jura Pelc
jirik.pelc1998 at gmail.com
Sat Oct 24 07:46:37 CEST 2020
So have here awkward behaving of code.
I have a block of code where originally was `dprintk` for debugging and
everything was fine.
But when I tried to remove it (for the sanity of debug output) kernel
crashed. (Both with `.configure.py --debug`)
I can't see why this is happing and most importantly WHY IS THIS HAPPENING?
both `print` and `dprintk` should not apply any change.
This is a copy of the issue:
https://gitlab.mff.cuni.cz/teaching/nswi004/2020/team-please_dont/-/issues/15
related to branch
https://gitlab.mff.cuni.cz/teaching/nswi004/2020/team-please_dont/-/tree/bugfix/K-15
file: `heap.c/search_heap_size`
When running with `dprintk`, code will run smoothly and the result is
expected.
```c
*((int*)scanner) = 0xC0FFEE;
dprintk("Scanning: 0x%x (%x)\n", scanner, *((int*)scanner));
if(*((int*)scanner) != 0xC0FFEE)
```
``` shell
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x800fb130 (c0ffee)
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x800fc130 (c0ffee)
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x800fd130 (c0ffee)
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x800fe130 (c0ffee)
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x800ff130 (c0ffee)
[DEBUG src/mm/heap.c:24 search_heap_size()] Scanning: 0x80100130 (c0ffee)
[DEBUG src/mm/heap.c:27 search_heap_size()] NonMatch: 0x80100130 (ffffffff)
[DEBUG src/mm/heap.c:149 heap_init()] heap_begin: 0x80001130
[DEBUG src/mm/heap.c:150 heap_init()] heap_end: 0x800ff130
[DEBUG src/mm/heap.c:151 heap_init()] heap size: 1016 bytes
Hello world!
<msim> Alert: XHLT: Machine halt
Cycles: 229951
```
When running **Without** `dprintk`, code will fail during the process.
```c
*((int*)scanner) = 0xC0FFEE;
//dprintk("Scanning: 0x%x (%x)\n", scanner, *((int*)scanner));
if(*((int*)scanner) != 0xC0FFEE)
```
``` shell
<msim> Alert: XRD: Register dump
processor 0
0 0 at 0 v0 ffffffffc0000f20 v1
c0ffee a0 0
a1 0 a2 0 a3 0 t0
0 t1 0
t2 0 t3 0 t4 0 t5
0 t6 0
t7 0 s0 0 s1 0 s2
0 s3 0
s4 0 s5 0 s6 0 s7
0 t8 0
t9 0 k0 ff01 k1 0 gp
ffffffff80000000 sp ffffffff800003e8
fp 0 ra ffffffff80000440 pc ffffffff80000180 lo
0 hi 0
<msim> Alert: XINT: Interactive mode
[msim]
```
--
S pozdravem Jiří Pelc
Matematicko-fyzikální fakulta
Univerzita Karlova
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi004/attachments/20201024/f5450d8f/attachment.htm>
More information about the NSWI004
mailing list