When accessing
sub01(2....
i expect sig 11, but UW7 just gives a null-string.
I have attached a sample c-prog (tst01) to examine this case.
UW7 output
tst01 on UnixWare7, UNIX SVR4
-----------------------------------
1: 08049658 NOT NULL... '' <> px=0
2: 00000000 NULL... 0 <> px=0 this should
sig11 !!!!
3: FFFFFFFF NOT NULL...
Pos=3, Sig 11 trapped... good, -1
is recognized...
Linux result
tst01 on Linux and IRIX
-----------------------------------------
1: 0804858C NOT NULL... '' <> px=2565888
2: 00000000 NULL... 0 <(null)> caught by
printf
Pos=20, Sig 11 trapped... ok,
reference to 0X00
sample test "tst01.c"
--------------------------
#include <stdio.h>
#include <signal.h>
int pos=0;
void sub01();
void sig_trap();
/* ************************************************************* */
main()
{
signal (SIGSEGV, sig_trap);
sub01(1, "''", (char *)"");
sub01(2, "0 ", (char *)0);
sub01(3, "-1", (char *)-1);
printf("terminating...\n");
return(0);
}
/* ************************************************************* */
void sub01(int i1, char *s1, char *p1)
{ int px;
pos=i1;
printf("%d: ", pos);
if (p1 == (char *)0)
printf("%.8X NULL... ", (long)p1);
else
printf("%.8X NOT NULL... ", (long)p1);
printf("%s <%s>", s1, p1); /* null is caught in printf
(Linux, Irix) */
pos*=10;
memcpy((char *)&px, p1, sizeof(px)); /* dirty, I know, but must give sig11
*/
printf(" px=%d\n", px);
return;
}
/* ************************************************************** */
void sig_trap(int sig)
{
signal (SIGSEGV, sig_trap);
printf("\nPos=%d, Sig %d trapped...\n", pos, sig);
exit();
}
/* ************************************************************** */
Wolf Grossi schrieb:
See nullptr(1). By default the behavior is as you describe, but you can
change it to what you want. You can also change it from within a running
program; see sysi86(2).
--
Jonathan Schilling SCO, Inc. j...@sco.com
No question actually appears in your message. So I've just added
some speculation in...
"Wolf Grossi" <wg-...@magro-soft.com> writes:
>Hi folks,
> doing a port of a complex C-written software from svr4/unixware7.1 to
>linux/irix
>I'm running into the problem that UW7 does allow references to addresses
>pointing to 0X00, whereas Linux/IRIX gives sig 11 accessing an 0X00 address.
>When accessing
>sub01(2....
>i expect sig 11, but UW7 just gives a null-string.
UnixWare does that on purpose. (I find it annoying, personally.) As
dereferencing a null pointer is implementation-defined behaviour, it's
legal to do so.
Yuu can disable this behaviour for any given UID (not shell session -
it's system global across all processes owned by that UID and it does
persist across logouts) by doing a 'nullptr disable'. Then you can make
your program crash just like it does on Irix and Linux.
There's the minor little detail that many core OS utilities become
unstable when the system runs in this mode. (Yes, I'm on a jihad to get
the OS fixed, too....)
Of course, if this doesn't answer your question, perhaps actually
_asking_ one is in order. ;-)
RJL
: by doing a 'nullptr disable'. [...]
: There's the minor little detail that many core OS utilities become
: unstable when the system runs in this mode. (Yes, I'm on a jihad to get
: the OS fixed, too....)
Yes, that's true, alas. But it's important to note that the UnixWare 7
system *libraries* are safe to run with the null pointer kludge disabled.
That's why I pointed out that one can turn off the kludge from within one's
program as well as from the command line, by making a sysi86(SI86NULLPTR,...)
call. The SCO JVM JIT compiler does this, for example, in order to
efficiently implement Java's null reference checks by trapping null
pointer dereferences.