
Hi all, I recently found a suspicious piece of code in RTS code. * https://github.com/ghc/ghc/blob/master/rts/Profiling.c#L622 here it's checking that ccs is not EMPTY_STACK. * https://github.com/ghc/ghc/blob/master/includes/rts/prof/CCS.h#L96 here EMPTY_STACK is defined as NULL. Now weird part is that before the if-statement checks for `ccs != NULL` ccs is used to reach some of it's fields(for example, line 601 and 602). As far as I can see either we have a bug here or the if-statement is not necessary and we can move it's body to top level. Am I missing anything here? Thanks. --- Ömer Sinan Ağacan http://osa1.net

Hello Ömer, That does seem pretty suspicious. My interpretation is that ccs should just never be EMPTY_STACK. If we look at the calling codepaths, the only case that a NULL could be passed is if pushCostCentre is called with NULL ccs, but we only create these invocations in code generation and never pass a NULL in such situations. What I am not sure is if there is some special treatment for empty stacks that should be happening, but is not, at the moment. Edward Excerpts from Ömer Sinan Ağacan's message of 2014-06-02 08:19:21 -0700:
Hi all,
I recently found a suspicious piece of code in RTS code.
* https://github.com/ghc/ghc/blob/master/rts/Profiling.c#L622 here it's checking that ccs is not EMPTY_STACK. * https://github.com/ghc/ghc/blob/master/includes/rts/prof/CCS.h#L96 here EMPTY_STACK is defined as NULL.
Now weird part is that before the if-statement checks for `ccs != NULL` ccs is used to reach some of it's fields(for example, line 601 and 602). As far as I can see either we have a bug here or the if-statement is not necessary and we can move it's body to top level.
Am I missing anything here?
Thanks.
--- Ömer Sinan Ağacan http://osa1.net

We could probably remove that check. Cheers, Simon On 02/06/2014 19:09, Edward Z. Yang wrote:
Hello Ömer,
That does seem pretty suspicious. My interpretation is that ccs should just never be EMPTY_STACK. If we look at the calling codepaths, the only case that a NULL could be passed is if pushCostCentre is called with NULL ccs, but we only create these invocations in code generation and never pass a NULL in such situations.
What I am not sure is if there is some special treatment for empty stacks that should be happening, but is not, at the moment.
Edward
Excerpts from Ömer Sinan Ağacan's message of 2014-06-02 08:19:21 -0700:
Hi all,
I recently found a suspicious piece of code in RTS code.
* https://github.com/ghc/ghc/blob/master/rts/Profiling.c#L622 here it's checking that ccs is not EMPTY_STACK. * https://github.com/ghc/ghc/blob/master/includes/rts/prof/CCS.h#L96 here EMPTY_STACK is defined as NULL.
Now weird part is that before the if-statement checks for `ccs != NULL` ccs is used to reach some of it's fields(for example, line 601 and 602). As far as I can see either we have a bug here or the if-statement is not necessary and we can move it's body to top level.
Am I missing anything here?
Thanks.
--- Ömer Sinan Ağacan http://osa1.net
ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs
participants (3)
-
Edward Z. Yang
-
Simon Marlow
-
Ömer Sinan Ağacan