haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
97 stars 62 forks source link

getMessage/peekMessage fail to detect return errors #145

Closed tmcl closed 4 years ago

tmcl commented 4 years ago

Current Behavior

Back in 2018, #119 replaced -1 :: LONG with maxBound :: LONG in the implementation of getMessage and peekMessage. This is not correct since -1 :: LONG is FFFF FFFF, whereas maxBound :: LONG is only 7FFF FFFF. Consequently, error cases are not correctly identified. (LONG = Int32. Note that under the Windows.h definition of getMessage, they return BOOL = int ~= our INT = Int32, but we are saying they return LONG = Int32.)

Steps to Reproduce (for bugs)

  1. Use the same Main.hs file I provided in #142
  2. Test on a version from 2.8.2 on.
  3. Close the window.
  4. Notice the process is stuck in an infinite loop as it perpetually receives an error and never reaches a terminating condition. (On the other hand, I thought the code should have returned FALSE = False and got let out of the loop on another ground.)

Your Environment