APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds RSS Feeds











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version


null pointers

What confuses me here is the date - Unixware had "nullptr", but did Linux have it ? And if it did, was it really what Jonathan mentions or was it just a replacement for comparing null pointers?


From: jls@sco.com (J. L. Schilling)
Newsgroups: comp.unix.sco.misc
Subject: Re: pointer sisters ...ah...question
Date: 22 Jun 2000 18:40:11 GMT
Message-ID: <8itmib$m5r$1@hobbes.sco.com> 
References: <8it7pl$tjk$1@rohrpostix.uta4you.at> 

Wolf Grossi (wg-news@magro-soft.com) wrote:
: 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.

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.               jls@sco.com

From - Thu Jun 22 15:04:42 2000
From: Frank Langelage <langel@st-oneline.de>
Newsgroups: comp.unix.sco.misc
Subject: Re: pointer sisters ...ah...question
Date: Thu, 22 Jun 2000 20:26:33 +0200
Message-ID: <39525A59.EDD056A6@st-oneline.de> 
References: <8it7pl$tjk$1@rohrpostix.uta4you.at> 
X-Server-Date: 22 Jun 2000 18:32:07 GMT

On UW there is an Kernel Parameter called NULLPTR which controls this.
Default is 1: null-ptr reads are allowed
Set this to 0, if you want to get SIG 11 in your case.
















Wolf Grossi schrieb:

> 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.
>
> 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();
> }
> /* ************************************************************** */

From - Fri Jun 23 06:37:57 2000
From: jls@sco.com (J. L. Schilling)
Newsgroups: comp.unix.sco.programmer,comp.unix.sco.misc
Subject: Re: pointer sisters ...ah...question
Date: 23 Jun 2000 00:54:34 GMT
Message-ID: <8iucga$2ti$1@hobbes.sco.com> 
References: <8it7pl$tjk$1@rohrpostix.uta4you.at>
<sl4v52l3e7f24@corp.supernews.com> Robert Lipe (robertlipe@usa.net) wrote: : 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.

--
Jonathan Schilling              SCO, Inc.               jls@sco.com



If this page was useful to you, please help others find it:  





Comments?




More Articles by Tony Lawrence - Find me on Google+



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

pavatar.jpg

This post tagged:

       - Conversion
       - Linux
       - Unixware


















My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!


book graphic unix and linux troubleshooting guide



Buy Kerio from a dealer
who knows tech:
I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals