fread then fclose => mempartfree error - VxWorks

This is a discussion on fread then fclose => mempartfree error - VxWorks ; Hi all, we got a serious problem when opening a file. We run on PQ2, VME bus, PCI SCSI controler board linked to a SCSI VME disk board. With VxWorks 5.5. I am able to create files on SCSI board, ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: fread then fclose => mempartfree error

  1. fread then fclose => mempartfree error

    Hi all,
    we got a serious problem when opening a file.
    We run on PQ2, VME bus, PCI SCSI controler board linked to a SCSI VME disk
    board. With VxWorks 5.5.
    I am able to create files on SCSI board, but not to read them without
    errors.
    The sequence fopen fread fclose crashes with message about mempartfree
    error, even for very small read (10 bytes fread causes pb too...)
    But, the sequence fopen setbuf fread fclose (i.e. allocate buffer file in
    heap manually with malloc) doesnt crash! So we got a small workaround for
    the moment but this is not the right way because we dont want to manage the
    buffer.
    I have tryed to increase stack size without success.

    Any idea is welcome...

    Note that we dont have any problem with an ATA drive (on a PCI board).
    Another point: dumping file pointer between each step show the automatic
    allocation (crash sequence) is done for a 0x8000 sized buffer (32kB) for
    SCSI test. The same dump with ATA show the buffer is only 16 kB large. May
    be a way to follow. I dont really know.

    Thanks a lot.
    Nicolas

  2. Re: fread then fclose => mempartfree error

    Nico wrote:
    > Hi all,
    > we got a serious problem when opening a file.
    > We run on PQ2, VME bus, PCI SCSI controler board linked to a SCSI VME disk
    > board. With VxWorks 5.5.
    > I am able to create files on SCSI board, but not to read them without
    > errors.
    > The sequence fopen fread fclose crashes with message about mempartfree
    > error, even for very small read (10 bytes fread causes pb too...)
    > But, the sequence fopen setbuf fread fclose (i.e. allocate buffer file in
    > heap manually with malloc) doesnt crash! So we got a small workaround for
    > the moment but this is not the right way because we dont want to manage the
    > buffer.
    > I have tryed to increase stack size without success.
    >
    > Any idea is welcome...
    >
    > Note that we dont have any problem with an ATA drive (on a PCI board).
    > Another point: dumping file pointer between each step show the automatic
    > allocation (crash sequence) is done for a 0x8000 sized buffer (32kB) for
    > SCSI test. The same dump with ATA show the buffer is only 16 kB large. May
    > be a way to follow. I dont really know.
    >
    > Thanks a lot.
    > Nicolas



    Nico,
    The cause for mempartfree is generally double free.
    Make sure you dont do that.


    Subhash


  3. Re: fread then fclose => mempartfree error

    Hi,
    thanks for answer. I have already tried this way but here, its really the
    fclose instruction after fread which causes the issue. Here is an example
    of code which ends in mempartfree error:

    FILE * fp;
    char buffer[20] = {0,};

    fp = fopen("/sd0/foo","r");
    if (NULL == fp) return ERROR;

    fread(buffer,sizeof(char),10,fp);

    fclose(fp);
    return OK;

    On fclose, i got invalid block mempartfree error.. :-(

    Nicolas




    "Subhash" wrote in
    news:1145228212.701105.286020@z34g2000cwc.googlegr oups.com:

    > Nico wrote:
    >> Hi all,
    >> we got a serious problem when opening a file.
    >> We run on PQ2, VME bus, PCI SCSI controler board linked to a SCSI VME
    >> disk board. With VxWorks 5.5.
    >> I am able to create files on SCSI board, but not to read them without
    >> errors.
    >> The sequence fopen fread fclose crashes with message about
    >> mempartfree error, even for very small read (10 bytes fread causes pb
    >> too...) But, the sequence fopen setbuf fread fclose (i.e. allocate
    >> buffer file in heap manually with malloc) doesnt crash! So we got a
    >> small workaround for the moment but this is not the right way because
    >> we dont want to manage the buffer.
    >> I have tryed to increase stack size without success.
    >>
    >> Any idea is welcome...
    >>
    >> Note that we dont have any problem with an ATA drive (on a PCI
    >> board). Another point: dumping file pointer between each step show
    >> the automatic allocation (crash sequence) is done for a 0x8000 sized
    >> buffer (32kB) for SCSI test. The same dump with ATA show the buffer
    >> is only 16 kB large. May be a way to follow. I dont really know.
    >>
    >> Thanks a lot.
    >> Nicolas

    >
    >
    > Nico,
    > The cause for mempartfree is generally double free.
    > Make sure you dont do that.
    >
    >
    > Subhash
    >
    >



+ Reply to Thread