Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Risk of memory leak if branch is taken? #393

Open
hinxx opened this issue Mar 30, 2019 · 1 comment
Open

Risk of memory leak if branch is taken? #393

hinxx opened this issue Mar 30, 2019 · 1 comment

Comments

@hinxx
Copy link
Contributor

hinxx commented Mar 30, 2019

In the light of recent memory leak plugs, looking at the

if (status != asynSuccess){

makes me think we might need to look into this edge case, to avoid having a similar memory leak as in #385 (fixed via #390).

@hinxx
Copy link
Contributor Author

hinxx commented Mar 30, 2019

By triggering the branch using if (true) instead of the status check and adding a object count printout before the call to H5Fclose() at line 1496:

    int obj_count = (int)H5Fget_obj_count(this->file, H5F_OBJ_ALL);
    if (obj_count > 0){
      fprintf(stderr,
                "%s::%s Closing file not totally clean.  All remaining=%d\n",
                driverName, functionName, obj_count);
    }

I get the following printouts in the IOC shell:

2019/03/30 12:22:50.995 NDFileHDF5::writeFile ERROR: could not write to dataset. Aborting
NDFileHDF5::writeFile Closing file not totally clean.  All remaining=8
2019/03/30 12:22:50.995 NDPluginFile::writeFileBase Error writing file, status=3

The IOC crashed with segfault after the first image was not written (I might be the cause of that with the crude forcing the execution of failed code branch).

GDB says:

Thread 144 "FileHDF1_Plugin" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffea76a700 (LWP 18139)]
0x00007ffff7965b21 in NDFileHDF5::createHardLinks (this=this@entry=0x5555559c68a0, root=0x7fffe0190950) at ../NDFileHDF5.cpp:715
715	      std::string linkName = it_hardlinks->second->get_full_name();
(gdb) bt
#0  0x00007ffff7965b21 in NDFileHDF5::createHardLinks (this=this@entry=0x5555559c68a0, root=0x7fffe0190950) at ../NDFileHDF5.cpp:715
#1  0x00007ffff7965c94 in NDFileHDF5::createHardLinks (this=this@entry=0x5555559c68a0, root=<optimized out>) at ../NDFileHDF5.cpp:728
#2  0x00007ffff7965d3c in NDFileHDF5::createHardLinks (this=this@entry=0x5555559c68a0, root=<optimized out>) at ../NDFileHDF5.cpp:707
#3  0x00007ffff797392f in NDFileHDF5::openFile (this=0x5555559c68a0, fileName=0x7fffea769780 "/tmp/test_hdf5_1.h5", openMode=<optimized out>, pArray=0x7ffef00597b0) at ../NDFileHDF5.cpp:305
#4  0x00007ffff7962f76 in NDPluginFile::openFileBase (this=this@entry=0x5555559c68a0, openMode=openMode@entry=2, pArray=pArray@entry=0x7ffef00597b0) at ../NDPluginFile.cpp:73
#5  0x00007ffff7963b6c in NDPluginFile::writeFileBase (this=this@entry=0x5555559c68a0) at ../NDPluginFile.cpp:254
#6  0x00007ffff796434f in NDPluginFile::processCallbacks (this=0x5555559c68a0, pArray=0x7ffef00597b0) at ../NDPluginFile.cpp:756
#7  0x00007ffff78feaf2 in NDPluginDriver::processTask (this=0x5555559c68a0) at ../NDPluginDriver.cpp:524
#8  0x00007ffff64546d9 in epicsThreadCallEntryPoint (pPvt=0x7fffbc001060) at ../../../src/libCom/osi/epicsThread.cpp:83
#9  0x00007ffff645ac28 in start_routine (arg=0x7fffbc001530) at ../../../src/libCom/osi/os/posix/osdThread.c:403
#10 0x00007ffff3d0b6db in start_thread (arg=0x7fffea76a700) at pthread_create.c:463
#11 0x00007ffff614688f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant