[GHC] #12636: ProfHeap's printf modifiers are incorrect

#12636: ProfHeap's printf modifiers are incorrect ----------------------------------------+--------------------------------- Reporter: Phyx- | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Keywords: newcomer | Operating System: Windows Architecture: Unknown/Multiple | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------------- during compile I noticed {{{ rts\ProfHeap.c: In function 'dumpCensus': rts\ProfHeap.c:768:26: error: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=] fprintf(hp_file, "VOID\t%lu\n", ^ rts\ProfHeap.c:770:26: error: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=] fprintf(hp_file, "LAG\t%lu\n", ^ rts\ProfHeap.c:772:26: error: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=] fprintf(hp_file, "USE\t%lu\n", ^ rts\ProfHeap.c:774:26: error: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=] fprintf(hp_file, "INHERENT_USE\t%lu\n", ^ rts\ProfHeap.c:776:26: error: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int' [-Wformat=] fprintf(hp_file, "DRAG\t%lu\n", ^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bollu): I would like to take this up, do I simply assign it to myself? thanks -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): Yup, go ahead. This task probably just involves replacing these hardcoded format specifiers with the correct ones from https://github.com/ghc/ghc/blob/master/includes/stg/Types.h. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: bollu Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bollu): * owner: => bollu -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: bollu Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bollu): Why does the `Census` type `ssize_t` for `void_total`, `drag_total`, etc? wouldn't `size_t` be more appropriate, as they don't seem to be using the _signed_ property of `ssize_t`? The piece of code that causes the warning is {{{ fprintf(hp_file, "LAG\t%lu\n", (unsigned long)(census->not_used - census->void_total) * sizeof(W_)); }}} The `sizeof(W_) :: size_t` and `census->not_used :: ssize_t`. The solution that I'm proposing is to cast the `ssize_t` to a `size_t` and then change the format specifier to `%zu` as discussed on StackOverflow: [http://stackoverflow.com/questions/2125845/platform-independent-size-t -format-specifiers-in-c] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: bollu Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): I actually question the use of `ssize_t` at all for these values. I think the calculations violate the expected value ranges of `ssize_t` namely with {{{ censuses[t].void_total += size; censuses[era].void_total -= size; }}} So I think the types in `_counter` are wrong and have the potential to do an unsigned underflow as `ssize_t` is only guaranteed to be able to store values between `[-1, {SSIZE_MAX}]`[1] [1]http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: Siddharth | Bhat Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3129 Wiki Page: | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => patch * differential: => Phab:D3129 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect
-------------------------------------+-------------------------------------
Reporter: Phyx- | Owner: bollu
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Runtime System | Version: 8.0.1
Resolution: | Keywords: newcomer
Operating System: Windows | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3129
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3129 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * owner: bollu => (none) * status: patch => new * milestone: => 8.2.1 Comment: Phyx may have a point in comment:5 so I'm going to leave this open. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3129 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bollu): I'm not sure what the expected solution is for the underflow bug. If Phyx / bgmari have ideas, I'd be glad to implement it -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3129 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): It may be that it isn't a problem. In case it is, we should add an assert before `censuses[era].void_total -= size;`. `assert (censuses[era].void_total >= size);` at least this way, if it is a problem we'll trigger it. if it's not it also makes it clear to the next person that we've thought about it and it's not an issue. if it turns out to be a problem, then we should replace `ssize_t` with a normal signed type like `uint64_t` or something. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12636: ProfHeap's printf modifiers are incorrect -------------------------------------+------------------------------------- Reporter: Phyx- | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: newcomer Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3129 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): These counts can legitimately be negative, so we should use real signed types here. Sorry I didn't notice this earlier. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12636#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC