X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=774de72e380cb0c29e6fe9db9069c6fca239c553;hb=030ecd78112d9db9a83d156d431a993cbcd64eab;hp=4f42823d4ae5f7dc946022b877b896c5118c6835;hpb=50c4d03919a9d5c37c14004e964083251f655e93;p=ghc-hetmet.git diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index 4f42823..774de72 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -330,7 +330,9 @@ hs_add_root(void (*init_root)(void)) { bdescr *bd; nat init_sp; - Capability *cap = &MainCapability; + Capability *cap; + + cap = rts_lock(); if (hs_init_count <= 0) { barf("hs_add_root() must be called after hs_init()"); @@ -357,6 +359,8 @@ hs_add_root(void (*init_root)(void)) // ToDo: make this work in the presence of multiple hs_add_root()s. initProfiling2(); + rts_unlock(cap); + // ditto. #if defined(THREADED_RTS) ioManagerStart(); @@ -499,7 +503,7 @@ hs_exit_(rtsBool wait_foreign) // Originally, this was in report_ccs_profiling(). Now, retainer // profiling might tack some extra stuff on to the end of this file // during endProfiling(). - fclose(prof_file); + if (prof_file != NULL) fclose(prof_file); #endif #if defined(TICKY_TICKY)