[haiku-bugs] Re: [Haiku] #16337: Segment violation on x86_64 in bbitmap

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Thu, 02 Jul 2020 23:22:11 -0000

#16337: Segment violation on x86_64 in bbitmap
------------------------+-------------------------
  Reporter:  bbjimmy    |      Owner:  nobody
      Type:  bug        |     Status:  closed
  Priority:  normal     |  Milestone:  Unscheduled
 Component:  - General  |    Version:  R1/beta2
Resolution:  invalid    |   Keywords:
Blocked By:             |   Blocking:
  Platform:  All        |
------------------------+-------------------------
Changes (by mmlr):

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

Comment:

 This isn't a Haiku bug but one in yab. As the stack trace suggests, it
 ends up in YabInterface::BitmapSave() where it shouldn't be at all as it
 is only supposed to load an image. The reason is a missing return
 statement in yi_BitmapLoad which leads to undefined behaviour. In this
 specific case, the version built for x86_64 misses the final stack pop and
 ret, so after the call to YabInterface::BitmapLoad() it simply continues
 running. The next function happens to be YabInterface::BitmapSave() which
 is then run with a bogus stack and crashes.

 The compiler does point the issue out as a warning (even by default) but,
 as the function called may or may not actually return, it can't simply
 treat it as an error outright. In almost all cases you really do want to
 heed those warnings though and one should IMHO always strive for "-Wall
 -Wextra -Werror" to have such mistakes break the build instead of getting
 subtly broken binaries. The codebase has more of these return value and
 other issues (like calling "sprintf(stderr, ...)" which probably should
 have been "fprintf(stderr, ...)" instead) that would've been caught this
 way.
-- 
Ticket URL: <https://dev.haiku-os.org/ticket/16337#comment:4>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: