core dump on writing to pipe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mojozoox

    core dump on writing to pipe

    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

  • Walter Roberson

    #2
    Re: core dump on writing to pipe

    In article <1114492407.289 416.279370@g14g 2000cwa.googleg roups.com>,
    mojozoox <madireddy@HotP op.com> wrote:[color=blue]
    >Could you tell me scenarios in which core's dumped when writing to a
    >pipe.[/color]

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

    [color=blue]
    >write (pipefd,&Struct ,structsize);[/color]
    [color=blue]
    >on windows too this give a memory "read" violation. Could anyone tell
    >me why.[/color]

    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.
    --
    "[...] it's all part of one's right to be publicly stupid." -- Dave Smey

    Comment

    • SM Ryan

      #3
      Re: core dump on writing to pipe

      "mojozoox" <madireddy@HotP op.com> wrote:
      # 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,&S truct,structsiz e)
      and see if the output looks rational.

      --
      SM Ryan http://www.rawbw.com/~wyrmwif/
      What kind of convenience store do you run here?

      Comment

      • CBFalconer

        #4
        Re: core dump on writing to pipe

        SM Ryan wrote:[color=blue]
        > "mojozoox" <madireddy@HotP op.com> wrote:
        >[color=green]
        >> 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[/color]
        >
        > How about adding fprintf(stderr, "%d %p %d\n',pipefd,&S truct,structsiz e)
        > and see if the output looks rational.[/color]

        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.

        --
        Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
        Available for consulting/temporary embedded and systems.
        <http://cbfalconer.home .att.net> USE worldnet address!


        Comment

        • Keith Thompson

          #5
          Re: core dump on writing to pipe

          CBFalconer <cbfalconer@yah oo.com> writes:[color=blue]
          > SM Ryan wrote:[color=green]
          >> "mojozoox" <madireddy@HotP op.com> wrote:
          >>[color=darkred]
          >>> 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[/color]
          >>
          >> How about adding fprintf(stderr, "%d %p %d\n',pipefd,&S truct,structsiz e)
          >> and see if the output looks rational.[/color]
          >
          > 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.[/color]

          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.

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • mojozoox

            #6
            Re: core dump on writing to pipe

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

            Comment

            • Walter Roberson

              #7
              Re: core dump on writing to pipe

              In article <1115043438.597 404.200990@l41g 2000cwc.googleg roups.com>,
              mojozoox <madireddy@HotP op.com> wrote:[color=blue]
              >is there way to read a core file kindly let me know![/color]

              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.
              --
              Beware of bugs in the above code; I have only proved it correct,
              not tried it. -- Donald Knuth

              Comment

              • Flash Gordon

                #8
                Re: core dump on writing to pipe

                mojozoox wrote:[color=blue]
                > is there way to read a core file kindly let me know![/color]

                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.
                --
                Flash Gordon
                Living in interesting times.
                Although my email address says spam, it is real and I read it.

                Comment

                • SM Ryan

                  #9
                  Re: core dump on writing to pipe

                  "mojozoox" <madireddy@HotP op.com> wrote:
                  # 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.


                  --
                  SM Ryan http://www.rawbw.com/~wyrmwif/
                  So basically, you just trace.

                  Comment

                  Working...