When I tryied to generate a ResNet-50, the application n2d2 crashed with a segfault.
Cause
After debug, I found that this crash was made by the function N2D2::Utils::exec :
The function popen returned a NULL pointer and triggers a runtime_error
This exception call the destructor of the pipe object (which is a shared_pointer)
The cpp specification for shared_pointer says that Unlike std::unique_ptr, the deleter of std::shared_ptr is invoked even if the managed pointer is null.
So, the function pclose (registered as deleter) is called with a NULL pointer and make the app crash
Fix
To fix this Issue, I replaced the shared_ptr by a unique_ptr which is better in that case because :
The pointer used here is not "shared" but "unique" because created and deleted in the same function
The cpp specification for unique_ptr says that If get() == nullptr there are no effects. Otherwise, the owned object is destroyed via get_deleter()(get()).
Includes missing
Encountered issue
On Centos7, I couldn't manage to build the n2d2 target because of some includes missing.
Cause
In the file include/RangeStats.hpp, some unordered_map are declared but only the map header is included.
In the file src/RangeStats.hpp, the function assert is called without the inclusion of cassert.
Fix
Just added the missing includes in the files and remove useless ones.
Coverage decreased (-0.0005%) to 19.586% when pulling 3b95d3ced54ca7d2c0948abe6c41498e470ec270 on GasparQ:master into d66da81cdc7c1dce6ac9d29ebf586d5a4fa16d74 on CEA-LIST:master.
Popen error
Encountered issue
When I tryied to generate a ResNet-50, the application n2d2 crashed with a segfault.
Cause
After debug, I found that this crash was made by the function
N2D2::Utils::exec
:popen
returned aNULL
pointer and triggers aruntime_error
pipe
object (which is ashared_pointer
)shared_pointer
says thatUnlike std::unique_ptr, the deleter of std::shared_ptr is invoked even if the managed pointer is null.
pclose
(registered as deleter) is called with aNULL
pointer and make the app crashFix
To fix this Issue, I replaced the
shared_ptr
by aunique_ptr
which is better in that case because :unique_ptr
says thatIf get() == nullptr there are no effects. Otherwise, the owned object is destroyed via get_deleter()(get()).
Includes missing
Encountered issue
On Centos7, I couldn't manage to build the
n2d2
target because of some includes missing.Cause
In the file
include/RangeStats.hpp
, someunordered_map
are declared but only themap
header is included.In the file
src/RangeStats.hpp
, the functionassert
is called without the inclusion ofcassert
.Fix
Just added the missing includes in the files and remove useless ones.
Popen failed ??!!??
In the function
N2D2::Utils::exec
and at the construction of aN2D2::Gnuplot
object, the functionpopen
is called.At some points, this function can fail and, in my case, it was because I didn't have enough memory on my environment (cf. #47).
Then I decided to improve error messages with
strerror
anderrno
in both cases.