ソースを参照

debugging of my weird error. details are on piazza, and can be inferred through comments and printfs when running uw-testbin/argtesttest

tarfeef101 6 年 前
コミット
2c7d850820

BIN
kern/compile/ASST2/kernel


+ 1 - 1
kern/compile/ASST2/vers.c

@@ -1,3 +1,3 @@
 /* This file is automatically generated. Edits will be lost.*/
-const int buildversion = 219;
+const int buildversion = 245;
 const char buildconfig[] = "ASST2";

+ 1 - 1
kern/compile/ASST2/version

@@ -1 +1 @@
-219
+245

+ 19 - 3
kern/syscall/proc_syscalls.c

@@ -215,7 +215,7 @@ int sys_execv(const char * program, userptr_t args)
   // allocate space for argv
   char ** argv = kmalloc(argcount * sizeof(char *));
   if (!argv) return ENOMEM;
-
+  
   // get kernel copy of args in argv
   temp = args;
   for (int i = 0; i < argcount; ++i)
@@ -238,6 +238,7 @@ int sys_execv(const char * program, userptr_t args)
       kfree(argv);
       return ENOMEM;
     }
+    
     errcode = copyinstr((userptr_t)*(char **)temp, argv[i], strLen, &wasteOfSpace);
     if (errcode)
     {
@@ -256,10 +257,25 @@ int sys_execv(const char * program, userptr_t args)
     kfree(argv);
     return ENOMEM;
   }
-  
+ 
   // get kernel copy of filepath
+  //size_t useless;
+  
+  for (int i = 0; i < argcount; ++i)
+  {
+    kprintf("arg: %d\n", strlen(argv[i]));
+  }
+
   size_t useless;
   errcode = copyinstr((const_userptr_t)program, filepath, strlen(program) + 1, &useless);
+
+  for (int i = 0; i < argcount; ++i)
+  {
+    kprintf("arg: %d\n", strlen(argv[i]));
+  }
+
+  // moving this part of the code (getting filepath) to the top did not make the problem go away, instead it gave me a malloc error trying to allocate argv
+
   if (errcode)
   {
     freeArgv(argv, argcount - 1);
@@ -267,7 +283,7 @@ int sys_execv(const char * program, userptr_t args)
     kfree(filepath);
     return errcode;
   }
-  
+ 
   // open program file
   struct vnode * v;
   errcode = vfs_open(filepath, O_RDONLY, 0, &v);