]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
fault
authorseantywork <seantywork@gmail.com>
Thu, 17 Apr 2025 07:50:16 +0000 (16:50 +0900)
committerseantywork <seantywork@gmail.com>
Thu, 17 Apr 2025 07:50:16 +0000 (16:50 +0900)
12 files changed:
0xgo/fault/.gitignore [new file with mode: 0644]
0xgo/fault/2504-03.xyz.md [new file with mode: 0644]
0xgo/fault/Makefile [new file with mode: 0644]
0xgo/fault/main.go [new file with mode: 0644]
fault/.gitignore [new file with mode: 0644]
fault/2504-03.xyz.md
fault/Makefile
fault/main.c
faults/.md [deleted file]
faults/Makefile [deleted file]
faults/infiniteloop.c [deleted file]
faults/null.c [deleted file]

diff --git a/0xgo/fault/.gitignore b/0xgo/fault/.gitignore
new file mode 100644 (file)
index 0000000..1c0ec3f
--- /dev/null
@@ -0,0 +1,2 @@
+*.prof
+*.png
\ No newline at end of file
diff --git a/0xgo/fault/2504-03.xyz.md b/0xgo/fault/2504-03.xyz.md
new file mode 100644 (file)
index 0000000..ad5c5d8
--- /dev/null
@@ -0,0 +1,28 @@
+# 
+
+
+```shell
+ 62         runtime.GC()
+ 63 
+ 64         cpuProfileBuff := &bytes.Buffer{}
+ 65 
+ 66         err := pprof.StartCPUProfile(cpuProfileBuff)
+ 67 
+ 68         if err != nil {
+ 69 
+ 70                 panic(err)
+ 71         }
+ 72 
+ 73         time.Sleep(time.Second * time.Duration(waits))
+ 74 
+ 75         pprof.StopCPUProfile()
+ 76 
+ 77         runtime.GC()
+ 78 
+ 79         profileBytes := cpuProfileBuff.Bytes()
+ 80 
+ 81         f, err := os.OpenFile("go.prof", os.O_CREATE|os.O_RDWR, 0644)
+ 82 
+
+
+```
\ No newline at end of file
diff --git a/0xgo/fault/Makefile b/0xgo/fault/Makefile
new file mode 100644 (file)
index 0000000..731062c
--- /dev/null
@@ -0,0 +1,3 @@
+all:
+       go build -o test.out .
+       
diff --git a/0xgo/fault/main.go b/0xgo/fault/main.go
new file mode 100644 (file)
index 0000000..b5ed409
--- /dev/null
@@ -0,0 +1,106 @@
+package main
+
+import (
+       "bytes"
+       "fmt"
+       "os"
+       "runtime"
+       "runtime/pprof"
+       "time"
+)
+
+var TLEN = 10
+
+func busy() {
+
+       val := 1
+       str := ""
+       for {
+
+               str = fmt.Sprintf("%d", val)
+
+               _ = str
+       }
+
+}
+
+func notbusy(idx int) {
+
+       val := 1
+       str := ""
+       for {
+
+               time.Sleep(time.Millisecond * 1)
+
+               str = fmt.Sprintf("%d", val)
+
+               fmt.Printf("i'm not busy: %d: %s\n", idx, str)
+
+       }
+}
+
+func threadFunc() {
+
+       for i := 0; i < TLEN; i++ {
+
+               if i == 5 {
+
+                       go busy()
+
+               } else {
+
+                       go notbusy(i)
+
+               }
+
+       }
+
+}
+
+func profiler(waits int) {
+
+       runtime.GC()
+
+       cpuProfileBuff := &bytes.Buffer{}
+
+       err := pprof.StartCPUProfile(cpuProfileBuff)
+
+       if err != nil {
+
+               panic(err)
+       }
+
+       time.Sleep(time.Second * time.Duration(waits))
+
+       pprof.StopCPUProfile()
+
+       runtime.GC()
+
+       profileBytes := cpuProfileBuff.Bytes()
+
+       f, err := os.OpenFile("go.prof", os.O_CREATE|os.O_RDWR, 0644)
+
+       if err != nil {
+
+               panic(err)
+       }
+
+       f.Write(profileBytes)
+
+       f.Close()
+
+}
+
+func main() {
+
+       go threadFunc()
+
+       go profiler(10)
+
+       for {
+
+               time.Sleep(time.Millisecond * 1000)
+
+       }
+
+}
diff --git a/fault/.gitignore b/fault/.gitignore
new file mode 100644 (file)
index 0000000..0f31176
--- /dev/null
@@ -0,0 +1 @@
+core
\ No newline at end of file
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c90a9030b5ce143cc47e3057d86b9f50210eb8b7 100644 (file)
@@ -0,0 +1,351 @@
+# 01
+
+```shell
+
+    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND               
+  45742 thy       20   0   84644   1680   1552 S 100.3   0.0   2:07.90 test.out              
+  31225 libvirt+  20   0   12.9g   7.0g  69804 S  19.6  22.5  22:46.38 qemu-system-x86       
+  29116 libvirt+  20   0 9254112   4.1g  70204 S  16.6  13.3  73:40.25 qemu-system-x86       
+  40943 thy       20   0 1166.6g 431092 106752 S   2.0   1.3   2:45.83 code               
+
+```
+
+
+
+# 
+
+
+```shell
+
+sudo top -H -p 45742
+
+    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                 
+  45748 thy       20   0   84644   1680   1552 R  99.9   0.0   4:11.45 test.out                                                
+  45742 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45743 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45744 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45745 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45746 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45747 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45749 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45750 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45751 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out                                                
+  45752 thy       20   0   84644   1680   1552 S   0.0   0.0   0:00.02 test.out     
+```
+
+
+# 02 
+
+
+```shell
+
+
+(gdb) info threads
+  Id   Target Id                                    Frame 
+* 1    Thread 0x7913aa088740 (LWP 45742) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=req@entry=0x7ffdf7064420, rem=rem@entry=0x7ffdf7064420) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  2    Thread 0x7913a55f66c0 (LWP 45752) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  3    Thread 0x7913a5df76c0 (LWP 45751) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  4    Thread 0x7913a65f86c0 (LWP 45750) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a65f7ea0, rem=0x7913a65f7e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  5    Thread 0x7913a6df96c0 (LWP 45749) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a6df8ea0, rem=0x7913a6df8e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  6    Thread 0x7913a75fa6c0 (LWP 45748) "test.out" 0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+  7    Thread 0x7913a7dfb6c0 (LWP 45747) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a7dfaea0, rem=0x7913a7dfae90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  8    Thread 0x7913a85fc6c0 (LWP 45746) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a85fbea0, rem=0x7913a85fbe90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  9    Thread 0x7913a8dfd6c0 (LWP 45745) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a8dfcea0, rem=0x7913a8dfce90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  10   Thread 0x7913a95fe6c0 (LWP 45744) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a95fdea0, rem=0x7913a95fde90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+  11   Thread 0x7913a9dff6c0 (LWP 45743) "test.out" 0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a9dfeea0, rem=0x7913a9dfee90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+
+
+```
+
+
+
+# 03
+
+```shell
+(gdb) thread 2
+[Switching to thread 2 (Thread 0x7913a55f66c0 (LWP 45752))]
+#0  thread_func (p=0x3c75ade0) at main.c:43
+43                  val = val ^ 1;
+```
+
+# 04
+```shell
+(gdb) step
+35                  if(nanosleep(&request , &remaing) < 0){
+(gdb) 
+__GI___nanosleep (req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
+warning: 24     ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
+(gdb) 
+25      in ../sysdeps/unix/sysv/linux/nanosleep.c
+(gdb) 
+__GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0, rem=0x7913a55f5e90)
+    at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:64
+warning: 64     ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
+(gdb) 
+66      in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
+(gdb) 
+78      in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
+(gdb) 
+__GI___pthread_enable_asynccancel () at ./nptl/cancellation.c:31
+warning: 31     ./nptl/cancellation.c: No such file or directory
+(gdb) 
+32      in ./nptl/cancellation.c
+(gdb) 
+33      in ./nptl/cancellation.c
+
+...CUT...
+
+(gdb) 
+thread_func (p=0x3c75ade0) at main.c:43
+43                  val = val ^ 1;
+(gdb) 
+35                  if(nanosleep(&request , &remaing) < 0){
+
+```
+
+# 05
+
+```shell
+
+ 33         for(;;){
+ 34 
+ 35             if(nanosleep(&request , &remaing) < 0){
+ 36 
+ 37                 printf("error sleep at: %d\n", *idx);
+ 38 
+ 39                 break;
+ 40 
+ 41             }
+ 42 
+ 43             val = val ^ 1;
+ 44 
+ 45         }
+
+
+```
+
+
+# 05
+
+```shell
+
+(gdb) break main.c:43 thread 2
+Breakpoint 3 at 0x4011eb: file main.c, line 43.
+(gdb) info break
+Num     Type           Disp Enb Address            What
+3       breakpoint     keep y   0x00000000004011eb in thread_func at main.c:43
+        stop only in thread 2
+
+```
+
+# 06
+
+```shell
+
+(gdb) step
+__GI___nanosleep (req=0x7913a55f5ea0, rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
+warning: 24     ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
+(gdb) 
+25      in ../sysdeps/unix/sysv/linux/nanosleep.c
+(gdb) 
+__GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0, rem=0x7913a55f5e90)
+    at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:64
+warning: 64     ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
+(gdb) 
+
+...CUT...
+
+(gdb) 
+__GI___clock_nanosleep (clock_id=<optimized out>, clock_id@entry=0, flags=flags@entry=0, req=0x7913a55f5ea0, 
+    rem=0x7913a55f5e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:80
+warning: 80     ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
+(gdb) 
+83      in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
+(gdb) 
+__GI___nanosleep (req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/nanosleep.c:26
+warning: 26     ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
+(gdb) 
+
+Thread 2 "test.out" hit Breakpoint 3, thread_func (p=0x3c75ade0) at main.c:43
+43                  val = val ^ 1;
+(gdb) 
+
+```
+
+
+#
+
+```shell
+
+(gdb) del 3
+(gdb) info break
+No breakpoints, watchpoints, tracepoints, or catchpoints.
+
+```
+
+#
+
+```shell
+(gdb) thread 3
+[Switching to thread 3 (Thread 0x7913a5df76c0 (LWP 45751))]
+#0  thread_func (p=0x3c75aca0) at main.c:35
+35                  if(nanosleep(&request , &remaing) < 0){
+(gdb)  break main.c:43 thread 3
+Breakpoint 13 at 0x4011eb: file main.c, line 43.
+(gdb) info break
+Num     Type           Disp Enb Address            What
+13      breakpoint     keep y   0x00000000004011eb in thread_func at main.c:43
+        stop only in thread 3
+
+
+```
+
+#
+
+```shell
+
+(gdb) step
+__GI___nanosleep (req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/nanosleep.c:24
+warning: 24     ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
+(gdb) 
+25      in ../sysdeps/unix/sysv/linux/nanosleep.c
+
+...CUT...
+
+Thread 3 "test.out" hit Breakpoint 13, thread_func (p=0x3c75aca0) at main.c:43
+43                  val = val ^ 1;
+
+```
+
+#
+
+```shell
+
+(gdb) thread 6
+[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
+#0  0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+27                  val = val ^ 1;
+(gdb) 
+
+```
+
+#
+
+```shell
+(gdb) thread 6
+[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
+#0  0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+27                  val = val ^ 1;
+(gdb) thread 5
+[Switching to thread 5 (Thread 0x7913a6df96c0 (LWP 45749))]
+#0  __GI___nanosleep (req=<optimized out>, rem=<optimized out>) at ../sysdeps/unix/sysv/linux/nanosleep.c:26
+warning: 26     ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory
+(gdb) thread 4
+[Switching to thread 4 (Thread 0x7913a65f86c0 (LWP 45750))]
+#0  0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a65f7ea0, rem=0x7913a65f7e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+warning: 78     ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory
+(gdb) thread 3
+[Switching to thread 3 (Thread 0x7913a5df76c0 (LWP 45751))]
+#0  0x00007913a9eecadf in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, 
+    req=0x7913a5df6ea0, rem=0x7913a5df6e90) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
+78      in ../sysdeps/unix/sysv/linux/clock_nanosleep.c
+(gdb) thread 6
+[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
+#0  0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+27                  val = val ^ 1;
+(gdb) thread 6
+[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
+#0  0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+27                  val = val ^ 1;
+(gdb) thread 6
+[Switching to thread 6 (Thread 0x7913a75fa6c0 (LWP 45748))]
+#0  0x00000000004011b0 in thread_func (p=0x3c75a8e0) at main.c:27
+27                  val = val ^ 1;
+
+```
+
+#
+
+
+```shell
+(gdb) info locals
+idx = 0x3c75a8e0
+val = 1
+request = {tv_sec = 0, tv_nsec = 500000000}
+remaing = {tv_sec = 0, tv_nsec = 558998877944888576}
+
+```
+
+# 
+
+```shell
+(gdb) print *idx
+$1 = 5
+
+```
+
+
+# 
+
+```shell
+thy@thy-Z370-HD3:~/hack/linux/linuxyz/fault$ ulimit -c
+0
+thy@thy-Z370-HD3:~/hack/linux/linuxyz/fault$ ulimit -c unlimited
+thy@thy-Z370-HD3:~/hack/linux/linuxyz/fault$ ulimit -c
+unlimited
+```
+#
+```shell
+thy@thy-Z370-HD3:~/hack/linux/linuxyz/fault$ ./test.out 2
+Segmentation fault (core dumped)
+
+```
+
+
+# 
+
+```shell
+thy@thy-Z370-HD3:~/hack/linux/linuxyz/fault$ ls
+2504-03.xyz.md  core  main.c  Makefile  test.out
+
+```
+
+
+# 
+
+```shell
+gdb ./test.out core
+
+...CUT...
+
+Core was generated by `./test.out 2'.
+Program terminated with signal SIGSEGV, Segmentation fault.
+#0  0x0000000000401265 in thread_func_segv (p=0x2a4c58e0) at main.c:71
+71              val = *segv;
+[Current thread is 1 (Thread 0x7320465fa6c0 (LWP 58184))]
+```
+
+#
+
+```shell
+(gdb) info locals
+idx = 0x2a4c58e0
+segv = 0x0
+val = 1
+request = {tv_sec = 0, tv_nsec = 500000000}
+remaing = {tv_sec = 3828123916168164467, tv_nsec = 876097848}
+(gdb) print *idx
+$1 = 5
+```
+
index 15cbce63e0e882f5fa0fe88eced2a38b41db27ed..0dd4447ba83cfdae0761d068b511a7d9f85b724f 100644 (file)
@@ -1,6 +1,6 @@
 all:
 
-       gcc 
+       gcc -g -o test.out main.c -lpthread
 
 clean:
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..b801100a652fc343d0bdbd9889260267aadac5cf 100644 (file)
@@ -0,0 +1,149 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <time.h>
+
+
+
+#define TLEN 10
+
+void* thread_func(void* p){
+
+    int* idx = (int*)p;
+
+    int val = 1;
+
+    struct timespec request, remaing; 
+
+    request.tv_sec = 0;
+    request.tv_nsec = 500000000L;
+
+    if(*idx == 5) {
+
+        for(;;){
+
+            val = val ^ 1;
+
+        }
+
+    } else {
+
+        for(;;){
+
+            if(nanosleep(&request , &remaing) < 0){
+
+                printf("error sleep at: %d\n", *idx);
+
+                break;
+
+            }
+
+            val = val ^ 1;
+
+        }
+
+    }
+
+    pthread_exit(NULL);
+}
+
+void* thread_func_segv(void* p){
+
+    int* idx = (int*)p;
+
+    int* segv = (int*)p;
+
+    int val = 1;
+
+    struct timespec request, remaing; 
+
+    request.tv_sec = 0;
+    request.tv_nsec = 500000000L;
+
+    if(*idx == 5) {
+
+        sleep(5);
+
+        segv = NULL;
+
+        val = *segv;
+
+        printf("%d\n", val);
+
+    } else {
+
+        for(;;){
+
+            if(nanosleep(&request , &remaing) < 0){
+
+                printf("error sleep at: %d\n", *idx);
+
+                break;
+
+            }
+
+            val = val ^ 1;
+
+        }
+
+    }
+
+    pthread_exit(NULL);
+}
+
+
+int main(int argc, char **argv){
+
+    pthread_t id[TLEN];
+
+    if(argc != 2){
+
+        printf("feed case\n");
+
+        return -1;
+    }
+
+    if(strcmp(argv[1], "1") == 0){
+
+        for(int i = 0; i < TLEN; i++){
+    
+            int* j = (int*)malloc(sizeof(int));
+    
+            *j = i;
+    
+            pthread_create(&id[i], NULL, thread_func, j);
+    
+        }
+    
+        
+        for(;;){
+    
+            sleep(1);
+    
+        }
+
+    } else if (strcmp(argv[1], "2") == 0){
+
+        for(int i = 0; i < TLEN; i++){
+    
+            int* j = (int*)malloc(sizeof(int));
+    
+            *j = i;
+    
+            pthread_create(&id[i], NULL, thread_func_segv, j);
+    
+        }
+    
+        
+        for(;;){
+    
+            sleep(1);
+    
+        }
+
+    }
+
+
+}
diff --git a/faults/.md b/faults/.md
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/faults/Makefile b/faults/Makefile
deleted file mode 100644 (file)
index 54f8099..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-all:
-
-       gcc -g -o il.out infiniteloop.c -lpthread
-
-       gcc -g -o n.out null.c
-
-clean:
-
-       rm -rf *.o *.out
\ No newline at end of file
diff --git a/faults/infiniteloop.c b/faults/infiniteloop.c
deleted file mode 100644 (file)
index 2259eb3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-
-
-
-#define TLEN 10
-
-void* thread_func(void* p){
-
-    int* idx = (int*)p;
-
-    int val = 1;
-
-    if(*idx == 5) {
-
-        printf("got 5\n");
-
-        for(;;){
-
-            val = val ^ 1;
-
-        }
-    }
-
-    pthread_exit(NULL);
-}
-
-int main(void){
-
-    pthread_t id[TLEN];
-
-
-    for(int i = 0; i < TLEN; i++){
-
-        int* j = (int*)malloc(sizeof(int));
-
-        *j = i;
-
-        pthread_create(&id[i], NULL, thread_func, j);
-
-    }
-
-    
-    for(;;){
-
-        sleep(1);
-
-    }
-}
diff --git a/faults/null.c b/faults/null.c
deleted file mode 100644 (file)
index d0ebfb2..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-
-struct human {
-
-    char name[32];
-    int age;
-
-};
-
-
-int main(void){
-
-    struct human** people = (struct human**)malloc(9 * sizeof(struct human*));
-
-    for(int i = 0 ; i < 9; i ++){
-
-        people[i] = (struct human*)malloc(sizeof(struct human));
-
-        memset(people[i], 0, sizeof(struct human));
-
-        sprintf(people[i]->name, "hello %d world", i);
-
-        people[i]->age = i + 10;
-
-    }
-
-    for(int i = 0; i < 10; i++){
-
-
-        printf("name: %s age: %d\n", people[i]->name, people[i]->age);
-
-    }
-
-}