[Hackage] #172: bug in zlib binding makes cabal-install segfault

Hackage trac at galois.com
Fri Feb 22 18:41:07 EST 2008

#172: bug in zlib binding makes cabal-install segfault
  Reporter:  guest   |        Owner:  duncan        
      Type:  defect  |       Status:  closed        
  Priority:  normal  |    Milestone:                
 Component:  misc    |      Version:                
  Severity:  normal  |   Resolution:  fixed         
  Keywords:          |   Difficulty:  hard (< 1 day)
Ghcversion:  6.6     |     Platform:  Linux         
Changes (by duncan):

  * status:  new => closed
  * resolution:  => fixed


 I think I've found the bug. I think it was caused by a change between
 zlib-1.1.x and 1.2.x but it was also my fault for not being sufficiently
 careful with error handling.

 My guess is that in zlib-1.1.x, functions like inflateInit can return
 error codes without setting the string error message `msg`. The zlib
 binding code was always looking at the `msg` member of the `z_stream`
 structure and trying to read a string error message from it. If the `msg`
 member was NULL then this would produce the behavior in the ltrace output
 above. So I've changed the error handling code to check if the `msg` is
 NULL before inspecting its contents.

 This should fix the segfault but it does not explain why `inflateInit2`
 was returning `Z_STREAM_ERROR`. The documentation says it can return
 `Z_STREAM_ERROR` "if a parameter is invalid (such as a negative memLevel)"
 but I cannot see what it is talking about since `memLevel` is a parameter
 to `deflateInit` not `inflateInit`.

 I've uploaded zlib-

 So I'm closing because I think the segfault is fixed. If you can still get
 a problem where decompressing the index file fails then re-open or file a
 new bug.

Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/172#comment:6>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects

More information about the cabal-devel mailing list