User: Password:
Subscribe / Log in / New account

GCC and pointer overflows

GCC and pointer overflows

Posted Apr 16, 2008 22:58 UTC (Wed) by neufeld (subscriber, #9124)
Parent article: GCC and pointer overflows

I once fixed a bug in a very popular application, it produced occasional bus errors on the
S390 architecture.  It turned out to be due to a piece of code of the form "buffer + len".
The C standard requires that you be able to create pointers in that form pointing to any
element in the allocated length, plus a single entry past the end.  It does not guarantee that
you can even compute the address of a pointer that lies outside this range.  "ptr + int"
calculation itself caused the bus error when the pointer lay near the end of the segment.

(Log in to post comments)

Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds