Post ABFWUdDJikc9ildnuq by pra@mstdn.io
(DIR) More posts by pra@mstdn.io
(DIR) Post #ABFHQQCwdVfiuf09Nw by wolf480pl@mstdn.io
2021-09-11T07:51:47Z
0 likes, 1 repeats
TIL on VAX (on which one of the first Unixes ran), the first two bytes of address space were always mapped and equal to zero. So if you accidentally used a null pointer as a string pointer, it behaved like an empty string. Which lead to many hard-to-find bugs that only appeared after porting your code to other architectures. Fun!
(DIR) Post #ABFWTwS2i7qN5zCSOm by pra@mstdn.io
2021-09-11T10:40:29Z
0 likes, 1 repeats
@wolf480pl HPUX must have adopted that behavior from VAX. Had a heck of a time porting a large complex app from HP to Solaris (back when those were relevant) until I discovered LD_PRELOAD and /usr/lib/0@0.so.
(DIR) Post #ABFWUdDJikc9ildnuq by pra@mstdn.io
2021-09-11T10:40:30Z
0 likes, 0 repeats
@wolf480pl @0.so. Some of our programmers were insisting that Sun's default behavior (segfaulting) was wrong, that null was a proper way to get a convenient null string.
(DIR) Post #ABFWXhvAfwaXBncVeK by pra@mstdn.io
2021-09-11T10:41:11Z
0 likes, 0 repeats
@wolf480pl Some of our programmers were insisting that Sun's default behavior (segfaulting) was wrong, that null was a proper way to get a convenient null string.
(DIR) Post #ABFWaI2pL9mVnsQsnQ by wolf480pl@mstdn.io
2021-09-11T10:41:38Z
0 likes, 0 repeats
@pra yeah, the Linkers and Loaders book mentions that many later unixes copied that behaviour because they didn't want to deal with the bugs
(DIR) Post #ABFWmKZZlZEn7TUZPc by wolf480pl@mstdn.io
2021-09-11T10:42:58Z
0 likes, 0 repeats
@pra wonder if you could just have a global char emptystr[] = "" and tell the linker to put it at 0
(DIR) Post #ABFZTb7qIcJuojHMXY by deavmi@mstdn.io
2021-09-11T11:14:03Z
0 likes, 0 repeats
@wolf480pl always mappedEw!