core dump on writing to pipe

M

mojozoox

Could you tell me scenarios in which core's dumped when writing to a
pipe.

write (pipefd,&Struct,structsize);

on windows too this give a memory "read" violation. Could anyone tell
me why.


thanks in advance.

mojo
 
W

Walter Roberson

Could you tell me scenarios in which core's dumped when writing to a
pipe.

Pipes are not part of standard C. Can you repeat the
problem with writing to a file opened for binary output?

write (pipefd,&Struct,structsize);
on windows too this give a memory "read" violation. Could anyone tell
me why.

structsize perhaps does not match sizeof(Struct) ?

The contents of Struct has perhaps not been initialized and
windows is perhaps detecting this?

pipefd might not be valid?

Struct might not even be the right type -- e.g., it might
really be a pointer to a structure and so you might be
taking the address of a pointer instead of passing
the address of a structure.
 
S

SM Ryan

# Could you tell me scenarios in which core's dumped when writing to a
# pipe.
#
# write (pipefd,&Struct,structsize);
#
# on windows too this give a memory "read" violation. Could anyone tell

How about adding fprintf(stderr,"%d %p %d\n',pipefd,&Struct,structsize)
and see if the output looks rational.
 
C

CBFalconer

SM said:
How about adding fprintf(stderr,"%d %p %d\n',pipefd,&Struct,structsize)
and see if the output looks rational.

Apart from the fact that there is no write(...) function in
standard C, and that Windoze is not Posix (neither of which is
on-topic here), your suggested diagnostic is one of the few places
that really need a cast. In this case (void*)&Struct.

Please correct your unconventional quote char. I edited this to
fix it.
 
K

Keith Thompson

CBFalconer said:
Apart from the fact that there is no write(...) function in
standard C, and that Windoze is not Posix (neither of which is
on-topic here), your suggested diagnostic is one of the few places
that really need a cast. In this case (void*)&Struct.

You might need casts for the other arguments as well. I'm guessing
pipefd is probably an int (if so, it doesn't need a cast), but
structsize is likely to be (and probably should be) a size_t.
 
W

Walter Roberson

is there way to read a core file kindly let me know!

A core file is like any other binary file -- just fopen() it
and fread() it.

Making sense of what you find there is a platform- and version-
specific problem.
 
F

Flash Gordon

mojozoox said:
is there way to read a core file kindly let me know!

Write a C program that opens it in binary more then reads it.

Alternatively, ask in a group dedicated to your system since we don't
deal with implementation specific tools here.
 
S

SM Ryan

# is there way to read a core file kindly let me know!

The debugger on your system. Perhaps gdb or sdb or dbg or dbx or mky mus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top