kayws426 / embox

Automatically exported from code.google.com/p/embox
0 stars 1 forks source link

exit() don't want to work #548

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. r8825; x86/nonvga_debug; gcc 4.7.2
2. apply diff
Index: src/cmds/help.c
===================================================================
--- src/cmds/help.c (revision 8825)
+++ src/cmds/help.c (working copy)
@@ -19,10 +19,12 @@
    printf("Usage: help [-h]\n");
 }

+#include <stdlib.h>
 static int exec(int argc, char **argv) {
    const struct cmd *cmd;
    int opt;

+   exit(0);
    getopt_init();
    while (-1 != (opt = getopt(argc, argv, "h"))) {
        switch (opt) {

3. run and call help

What is the expected output? What do you see instead?
Welcome to Embox and have a lot of fun!

embox>help

ASSERTION FAILED at src/kernel/thread/sched_strategy/priority_based.c : 202,
    in function runq_switch:

next != NULL
kernel debug panic

Backtrace:

     sp        pc         func + offset
     --------  --------  --------------------------
 30  00da65d8  0018f3e1  <__assertion_handle_failure+0x73>
 29  00da6618  0013a6fc  <runq_switch+0x104>
 28  00da6658  00147465  <sched_switch+0x68>
 27  00da6688  0013ad50  <critical_dispatch_pending+0x66>
 26  00da66c8  0013aff3  <sched_unlock+0x17>
 25  00da66e8  0013b46b  <task_exit+0x13e>
 24  00da6738  0018cfde  <exit+0x0>
 23  00da6758  0018cfef  <exit+0x11>
 22  00da6778  0012510a  <exec+0x12>
 21  00da6798  0017b9ee  <cmd_exec+0x27>
 20  00da67b8  0011f3e1  <run_cmd+0x62>
 19  00da67e8  0011f515  <shell_line_input+0xed>
 18  00da6908  0011f5aa  <shell_run+0x93>
 17  00da6cb8  0011f8d2  <run_script+0xc7>
 16  00da6ce8  0017cc97  <unit_mod_enable+0x53>
 15  00da6d18  0017c09a  <invoke_mod_enable+0x3d>
 14  00da6d48  0017c19c  <do_enable+0x53>
 13  00da6d78  0017bfac  <mod_traverse_rec_safe+0x13e>
 12  00da6dc8  0017bc95  <mod_enable_rec_safe+0x34>
 11  00da6df8  0017bcb0  <mod_enable+0x19>
 10  00da6e18  0017ca5f  <rl_mod_enable+0x43>
  9  00da6e58  0017c09a  <invoke_mod_enable+0x3d>
  8  00da6e88  0017c19c  <do_enable+0x53>
  7  00da6eb8  0017bfac  <mod_traverse_rec_safe+0x13e>
  6  00da6f08  0017bc95  <mod_enable_rec_safe+0x34>
  5  00da6f38  0017bcb0  <mod_enable+0x19>
  4  00da6f58  0017cbd2  <runlevel_enter+0x35>
  3  00da6f88  0017cb62  <runlevel_set+0x24>
  2  00da6fb8  0010022f  <init+0x24>
  1  00da6fe8  001001ed  <kernel_start+0x10>

QEMU: Terminated

Original issue reported on code.google.com by ki.stfu on 3 Mar 2013 at 7:28

GoogleCodeExporter commented 9 years ago

Original comment by ki.stfu on 3 Mar 2013 at 7:29

GoogleCodeExporter commented 9 years ago
It's because of we have one task (kernel_task) which has bootstrap and idle 
threads. When you exit it, we haven't any threads in system and it's causes an 
assertion.

Original comment by iantonishko on 4 Mar 2013 at 2:40

GoogleCodeExporter commented 9 years ago
i.e. we shouldn't use exit now? or may be should create separate task for 
command?

Original comment by ki.stfu on 4 Mar 2013 at 3:14

GoogleCodeExporter commented 9 years ago
that's right, `exit` is not valid cmd exit point

Original comment by drakon.m...@gmail.com on 6 Mar 2013 at 11:04