From 6f09e38deab590933740b8a7b0e5664f4e4d11ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 10 Jun 2004 01:43:16 +0000 Subject: [PATCH] team_create_team2() no longer panics if it couldn't create the userland stack - it just fails now (since create_area() currently panics when it fails, this is a cosmetic change anyway :-)). Now correctly cleans up in case elf_load_user_image() fails. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7883 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/team.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kernel/core/team.c b/src/kernel/core/team.c index eb6e436076..042b6f23fa 100644 --- a/src/kernel/core/team.c +++ b/src/kernel/core/team.c @@ -511,8 +511,7 @@ team_create_team2(void *args) // create an initial primary stack region // ToDo: make ENV_SIZE variable? - // ToDo: when B_BASE_ADDRESS is implemented, we could just allocate the stack from - // the bottom of the USER_STACK_REGION. + // ToDo: we could reserve the whole USER_STACK_REGION upfront... totalSize = PAGE_ALIGN(MAIN_THREAD_STACK_SIZE + TLS_SIZE + ENV_SIZE + get_arguments_data_size(teamArgs->args, teamArgs->argc)); @@ -523,7 +522,7 @@ team_create_team2(void *args) t->user_stack_region_id = create_area_etc(team, ustack_name, (void **)&t->user_stack_base, B_EXACT_ADDRESS, totalSize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); if (t->user_stack_region_id < 0) { - panic("team_create_team2: could not create default user stack region\n"); + dprintf("team_create_team2: could not create default user stack region\n"); return t->user_stack_region_id; } @@ -570,16 +569,19 @@ team_create_team2(void *args) path = teamArgs->path; TRACE(("team_create_team2: loading elf binary '%s'\n", path)); + // ToDo: don't use fixed paths! err = elf_load_user_image("/boot/beos/system/lib/rld.so", team, 0, &entry); - if (err < 0) { - // XXX clean up team - return err; - } // free the args free(teamArgs->path); free(teamArgs); + if (err < 0) { + // Luckily, we don't have to clean up the mess we created - that's + // done for us by the normal team deletion process + return err; + } + TRACE(("team_create_team2: loaded elf. entry = 0x%lx\n", entry)); team->state = TEAM_STATE_NORMAL;