[haiku-bugs] Re: [Haiku] #9687: [bin:kill] crashes if pid doesn't exit

  • From: "anevilyak" <trac@xxxxxxxxxxxx>
  • Date: Sat, 18 May 2013 01:01:53 -0000

#9687: [bin:kill] crashes if pid doesn't exit
-----------------------------------------------+---------------------------
   Reporter:  diver                            |      Owner:  anevilyak
       Type:  bug                              |     Status:  reopened
   Priority:  normal                           |  Milestone:  R1
  Component:  Applications/Command Line Tools  |    Version:
 Resolution:                                   |  R1/Development
 Blocked By:                                   |   Keywords:
Has a Patch:  0                                |   Blocking:
                                               |   Platform:  All
-----------------------------------------------+---------------------------
Changes (by anevilyak):

 * cc: bonefish (added)


Comment:

 Problem found: at http://cgit.haiku-
 os.org/haiku/tree/src/bin/coreutils/src/kill.c#L297 calls is_number,
 casting its pid argument to an intmax_t. However, on Haiku, pid_t is
 32-bit while intmax_t is 64-bit. Consequently, when is_number() writes the
 resulting value back at http://cgit.haiku-
 os.org/haiku/tree/src/bin/coreutils/src/kill.c#n235 , it also smashes the
 next 4 bytes on the stack. AFAICT from opengroup.org, our pid_t and
 intmax_t definitions are both spec compliant though, so I'm uncertain as
 to how this code manages to work OK on other platforms. The simple
 solution would seem to be to change is_number to simply accept a pid_t*
 instead. Thoughts?

--
Ticket URL: <http://dev.haiku-os.org/ticket/9687#comment:10>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: