Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Segmentation fault exceptions under DU4.0
@ 1998-02-13  5:00 turnergw-at-logica-dot-com
  1998-02-16  5:00 ` Segmentation fault exceptions under DU4.0 (msgrcv?) Jeff Sullivan
  1998-02-17  5:00 ` Segmentation fault exceptions under DU4.0 Jeff Sullivan
  0 siblings, 2 replies; 3+ messages in thread
From: turnergw-at-logica-dot-com @ 1998-02-13  5:00 UTC (permalink / raw)



I'm in the process of porting a large system from Digital Unix 3.2 to version 
4.0, and am experiencing a very frustrating problem: 

I'm getting sporadic exceptions which are causing processes to crash, of type 
segmentation violation, but only in specific cases. It seems to be mostly upon 
exiting a procedure which has received a message from another process. The 
message is invariably read correctly, and all the relevant data is correct, but 
something appears to be trashing the stack, as the process cannot exit the 
procedure cleanly.

This has been driving me mad for days, it works fine under 3.2.  Has anyone 
seen anything similar, is this a possiblw known compiler bug (it wouldn't be 
the first time)?

Any advice or information appreciated,

Cheers

Graham


-- 
Opinions expressed are my own, unless the company brainwashing really works...




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Segmentation fault exceptions under DU4.0 (msgrcv?)
  1998-02-13  5:00 Segmentation fault exceptions under DU4.0 turnergw-at-logica-dot-com
@ 1998-02-16  5:00 ` Jeff Sullivan
  1998-02-17  5:00 ` Segmentation fault exceptions under DU4.0 Jeff Sullivan
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Sullivan @ 1998-02-16  5:00 UTC (permalink / raw)
  To: turnergw-at-logica-dot-com


Are you using msgrcv() ?

We've run into that problem a few times recently. Take a look at
the response below for more info.

Potential data corruption in DIGITAL UNIX V4.0x with msgrcv()

A kernel change from V3.2 to V4.0 results in an application
error causing data corruption.  A signature of this problem is
that the 8 bytes immediately following the buffer are
overwritten with the size passed in to msgrcv()

The standard interface for msgrcv could be considered
unintuitive, particularly the specification of the msgsz
parameter.

The msgp parameter is the address of a buffer into which the
message type and message text are written.  The standard
specifies that this buffer is a structure consisting of a long
int, into which the message type is written followed by
application specific data.

For example, the following structure could be used: 

struct mymsg { 
    long int mtype;  /* for the message type */ 
    char mtext[123]; /* for the message data */ 
} 

The msgsz parameter is the size of the data following the
initial long int!  For instance, in the example above, it would
be correct to pass the size of mtext.  It is not correct to pass
sizeof(struct mymsg).

In DIGITAL UNIX V4.0, a change was made which results in writing
the last longword of the buffer, as specified by the address and
length passed in.  If the application incorrectly passes in the
size of the entire buffer, including the leading long, then this
will result in the long immediately following the buffer being
corrupted.  A signature of this problem is that the corrupted
cell will contain the value passed in the msgsz parameter to the
msgrcv service.


Let us know if this helps.

-Jeff

-- 
Jeff Sullivan | Digital Equipment Corp | E-mail:    jps@zk3.dec.com
DEC C and C++ | Nashua, NH  ZK3-2/2X09 | sullivan@decc.enet.dec.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Segmentation fault exceptions under DU4.0
  1998-02-13  5:00 Segmentation fault exceptions under DU4.0 turnergw-at-logica-dot-com
  1998-02-16  5:00 ` Segmentation fault exceptions under DU4.0 (msgrcv?) Jeff Sullivan
@ 1998-02-17  5:00 ` Jeff Sullivan
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Sullivan @ 1998-02-17  5:00 UTC (permalink / raw)



The user reported that this was, in fact, the problem and that it is
now resolved.

<quote>
It looks like we have been using the wrong message size in most of the
code, i.e. 8 bytes too big.  What really threw me was that the same code
to receive messages is used everywhere, in 30+ processes, and all but
one of them worked fine, whilst the one causing problems always crashed
in exactly the same manner, no matter what else I changed!

Anyway after much useless hacking and rewriting, a simple one line fix
has solved the problem ... I wish I'd posted the plea for help earlier
instead of ploughing through thousands of lines of code !
</quote>

I would also note that in DIGITAL UNIX V4.0, you also get the ATOM
tools. The tool I would highly recommend for cases like this, (memory
overwrites and the like) is "third degree". See the man page for
atom(1) and third(5). It is also described in the Programmer's Guide,
which should be available online.

-Jeff
-- 
Jeff Sullivan | Digital Equipment Corp | E-mail:    jps@zk3.dec.com
DEC C and C++ | Nashua, NH  ZK3-2/2X09 | sullivan@decc.enet.dec.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-02-17  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-13  5:00 Segmentation fault exceptions under DU4.0 turnergw-at-logica-dot-com
1998-02-16  5:00 ` Segmentation fault exceptions under DU4.0 (msgrcv?) Jeff Sullivan
1998-02-17  5:00 ` Segmentation fault exceptions under DU4.0 Jeff Sullivan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox