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

Ubuntu run time crash in malloc(): memory corruption #197

Closed
swframe opened this issue Aug 9, 2017 · 4 comments
Closed

Ubuntu run time crash in malloc(): memory corruption #197

swframe opened this issue Aug 9, 2017 · 4 comments
Labels
help wanted/question Extra attention is needed

Comments

@swframe
Copy link

swframe commented Aug 9, 2017

Issue summary

When I run the examples, I get a malloc error shown below.

Executed command (if any)

./build/examples/openpose/openpose.bin --logging_level 0 --image_dir examples/media/

OpenPose output (if any)

...
Finished initialization on thread. In src/openpose/pose/poseRenderer.cpp:initializationOnThread():88
./include/openpose/thread/thread.hpp:threadFunction():185
./include/openpose/pose/wPoseExtractor.hpp:work():55
./include/openpose/producer/wDatumProducer.hpp:workProducer():53
./include/openpose/producer/wDatumProducer.hpp:workProducer():65
./include/openpose/core/wCvMatToOpInput.hpp:work():55
./include/openpose/core/wCvMatToOpInput.hpp:work():65
./include/openpose/core/wCvMatToOpOutput.hpp:work():55
./include/openpose/core/wCvMatToOpOutput.hpp:work():67
./include/openpose/pose/wPoseExtractor.hpp:work():70
./include/openpose/pose/wPoseRenderer.hpp:work():55
./include/openpose/pose/wPoseRenderer.hpp:work():65
./include/openpose/pose/wPoseExtractor.hpp:work():55
./include/openpose/producer/wDatumProducer.hpp:workProducer():53
./include/openpose/thread/wQueueOrderer.hpp:work():111
./include/openpose/core/wOpOutputToCvMat.hpp:work():54
./include/openpose/producer/wDatumProducer.hpp:workProducer():65
./include/openpose/core/wCvMatToOpInput.hpp:work():55
./include/openpose/core/wCvMatToOpInput.hpp:work():65
./include/openpose/core/wCvMatToOpOutput.hpp:work():55
./include/openpose/core/wCvMatToOpOutput.hpp:work():67
*** Error in `./build/examples/openpose/openpose.bin': malloc(): memory corruption (fast): 0x00007efd2c0009d0 ***

Stack trace in debugger:
#0 0x00007ffff6942428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff694402a in __GI_abort () at abort.c:89
#2 0x00007ffff69847ea in __libc_message (do_abort=do_abort@entry=2,
fmt=fmt@entry=0x7ffff6a9de98 "*** Error in `%s': %s: 0x%s ***\n")
at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff698d37a in malloc_printerr (ar_ptr=, ptr=,
str=0x7ffff6a9df10 "free(): invalid next size (fast)", action=3) at malloc.c:5006
#4 _int_free (av=, p=, have_lock=0) at malloc.c:3867
#5 0x00007ffff699153c in __GI___libc_free (mem=) at malloc.c:2968
#6 0x00007ffff78604eb in op::WKeypointScaler<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::work(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) ()
from /home/user/nn/pose/openpose/.build_release/examples/openpose/../../lib/libopenpose.so.1.0.1
#7 0x00007ffff77abc0a in op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::checkAndWork(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) ()
from /home/user/nn/pose/openpose/.build_release/examples/openpose/../../lib/libopenpose.so.1.0.1
#8 0x00007ffff77afaab in op::SubThread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::workTWorkers(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&, bool) ()
from /home/user/nn/pose/openpose/.build_release/examples/openpose/../../lib/libopenpose.so.1.0.1
#9 0x00007ffff77b9087 in op::SubThreadQueueInOut<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > >, op::Queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::deque<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::allocator<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > > > >::work() ()
from /home/user/nn/pose/openpose/.build_release/examples/openpose/../../lib/libopenpose.so.1.0.1
#10 0x00007ffff77b47eb in op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::threadFunction() ()
from /home/user/nn/pose/openpose/.build_release/examples/openpose/../../lib/libopenpose.so.1.0.1
#11 0x00007ffff6fa5c80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#12 0x00007fffeed5e6ba in start_thread (arg=0x7fffc32ef700) at pthread_create.c:333
#13 0x00007ffff6a143dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

I ran it using valgrind and got this crash. Seems like OpenCV has a memory error.
==8727== Thread 6:
==8727== Invalid write of size 1
==8727== at 0x517716E: op::floatPtrToUCharCvMat(cv::Mat&, float const*, op::Point const&, int) (openCv.cpp:45)
==8727== by 0x525C508: op::OpOutputToCvMat::formatToCvMat(op::Array const&) const (opOutputToCvMat.cpp:20)
==8727== by 0x52A634E: op::WOpOutputToCvMat<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::work(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) (wOpOutputToCvMat.hpp:59)
==8727== by 0x51BD623: op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::checkAndWork(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) (worker.hpp:68)
==8727== by 0x51B58B5: op::SubThread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::workTWorkers(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&, bool) (subThread.hpp:82)
==8727== by 0x51B629A: op::SubThreadQueueInOut<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > >, op::Queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::deque<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::allocator<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > > > >::work() (subThreadQueueInOut.hpp:66)
==8727== by 0x51B7B0D: op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::threadFunction() (thread.hpp:190)
==8727== by 0x51D2828: void std::_Mem_fn_base<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)(), true>::operator()<, void>(op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >) const (in /home/hmullings/nn/pose/openpose/.build_debug/lib/libopenpose.so.1.0.1)
==8727== by 0x51D27BC: void std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (functional:1531)
==8727== by 0x51D256D: std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >)>::operator()() (functional:1520)
==8727== by 0x51D233D: std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >)> >::_M_run() (thread:115)
==8727== by 0x6D91C7F: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==8727== Address 0x97eadc15 is 1 bytes after a block of size 84 alloc'd
==8727== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8727== by 0x8BC9931: cv::fastMalloc(unsigned long) (in /usr/local/lib/libopencv_core.so.3.3.0)
==8727== by 0x8C66083: cv::Mat::create(int, int const*, int) (in /usr/local/lib/libopencv_core.so.3.3.0)
==8727== by 0x522F79E: cv::Mat::create(int, int, int) (mat.inl.hpp:784)
==8727== by 0x8C9212D: cv::_OutputArray::create(int, int, int, int, bool, int) const (in /usr/local/lib/libopencv_core.so.3.3.0)
==8727== by 0x8BBE8AB: cv::Mat::copyTo(cv::_OutputArray const&) const (in /usr/local/lib/libopencv_core.so.3.3.0)
==8727== by 0x51790CD: cv::Mat::Mat(std::initializer_list) (mat.inl.hpp:585)
==8727== by 0x5177017: op::floatPtrToUCharCvMat(cv::Mat&, float const*, op::Point const&, int) (openCv.cpp:34)
==8727== by 0x525C508: op::OpOutputToCvMat::formatToCvMat(op::Array const&) const (opOutputToCvMat.cpp:20)
==8727== by 0x52A634E: op::WOpOutputToCvMat<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::work(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) (wOpOutputToCvMat.hpp:59)
==8727== by 0x51BD623: op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::checkAndWork(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&) (worker.hpp:68)
==8727== by 0x51B58B5: op::SubThread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::workTWorkers(std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >&, bool) (subThread.hpp:82)
==8727==
--8727-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting
--8727-- si_code=128; Faulting address: 0x0; sp: 0x813017e20

Type of issue

  • Execution error

Your system configuration

Operating system (lsb_release -a in Ubuntu):
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

CUDA version (cat /usr/local/cuda/version.txt in most cases):
CUDA Version 8.0.61

cuDNN version:
/usr/lib/libcudnn.so.5.1.10

GPU model (nvidia-smi in Ubuntu):
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.66 Driver Version: 375.66 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 108... Off | 0000:02:00.0 On | N/A |
| 48% 68C P2 64W / 250W | 3503MiB / 11156MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 0000:03:00.0 Off | N/A |
| 35% 51C P2 58W / 250W | 596MiB / 11172MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

Caffe version: Default from OpenPose or custom version.
The default included with the git repo.

OpenCV version: installed with apt-get install libopencv-dev (Ubuntu) or default from OpenPose (Windows) or OpenCV 2.X or OpenCV 3.X.
OpenCV 3.X

Generation mode (only for Ubuntu): Makefile + Makefile.config (default, Ubuntu) or CMake (Ubuntu, Windows) or Visual Studio (Windows).
cmake version 3.5.1
I ran ./ubuntu/install_caffe_and_openpose_if_cuda8.sh

diff --git a/ubuntu/Makefile.config.Ubuntu16_cuda8.example b/ubuntu/Makefile.config.Ubuntu16_cuda8.example
index c2940dc..352002a 100644
--- a/ubuntu/Makefile.config.Ubuntu16_cuda8.example
+++ b/ubuntu/Makefile.config.Ubuntu16_cuda8.example
@@ -18,7 +18,7 @@ USE_CUDNN := 1
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
-# OPENCV_VERSION := 3
+OPENCV_VERSION := 3

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
@@ -92,7 +92,7 @@ BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to BVLC/caffe#171
-# DEBUG := 1
+DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

Compiler (gcc --version in Ubuntu):
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

@lvboodvl
Copy link

try to run it with "sudo":
sudo ./build/examples/openpose/openpose.bin --logging_level 0 --image_dir examples/media/

@swframe
Copy link
Author

swframe commented Aug 22, 2017

It crashes with a different stack trace:
#0 0x00007ffff560b428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff560d02a in __GI_abort () at abort.c:89
#2 0x00007ffff564d7ea in __libc_message (do_abort=do_abort@entry=2,
fmt=fmt@entry=0x7ffff5766e98 "*** Error in `%s': %s: 0x%s \n")
at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff5658651 in malloc_printerr (ar_ptr=0x7fffc2098400, ptr=0x7fffb00009d0,
str=0x7ffff57672a0 "malloc(): memory corruption (fast)", action=3) at malloc.c:5006
#4 _int_malloc (av=av@entry=0x7fffb0000020, bytes=bytes@entry=45) at malloc.c:3386
#5 0x00007ffff565a184 in __GI___libc_malloc (bytes=45) at malloc.c:2913
#6 0x00007ffff5c43e78 in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff5cd7aed in void std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_construct<char const
>(char const
, char const
, std::forward_iterator_tag) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00007ffff5cd7c4c in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff67f43d1 in op::WOpOutputToCvMat<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::work (this=0x7e3dd0, tDatums=std::shared_ptr (count 1, weak 0) 0x7fffbc0008d0)
at ./include/openpose/core/wOpOutputToCvMat.hpp:62
#10 0x00007ffff670b624 in op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > >::checkAndWork (this=0x7e3dd0, tDatums=std::shared_ptr (count 1, weak 0) 0x7fffbc0008d0)
at ./include/openpose/thread/worker.hpp:68
#11 0x00007ffff67038b6 in op::SubThread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::workTWorkers (this=0x7e55f0, tDatums=std::shared_ptr (count 1, weak 0) 0x7fffbc0008d0,
inputIsRunning=true) at ./include/openpose/thread/subThread.hpp:82
#12 0x00007ffff670429b in op::SubThreadQueueInOut<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > >, op::Queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::queue<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::deque<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::allocator<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > > > >::work (this=0x7e55f0) at ./include/openpose/thread/subThreadQueueInOut.hpp:66
#13 0x00007ffff6705b0e in op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::threadFunction (this=0x7e49a0) at ./include/openpose/thread/thread.hpp:190
#14 0x00007ffff6720829 in std::_Mem_fn_base<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)(), true>::operator()<, void>(op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >) const (this=0x7e5e60, __object=0x7e49a0) at /usr/include/c++/5/functional:600
#15 0x00007ffff67207bd in std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocator---Type to continue, or q to quit---
op::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >
)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x7e5e58)
at /usr/include/c++/5/functional:1531
#16 0x00007ffff672056e in std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >)>::operator()() (this=0x7e5e58) at /usr/include/c++/5/functional:1520
#17 0x00007ffff672033e in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >::)()> (op::Thread<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > >, std::shared_ptr<op::Worker<std::shared_ptr<std::vector<op::Datum, std::allocatorop::Datum > > > > >)> >::_M_run() (this=0x7e5e40) at /usr/include/c++/5/thread:115
#18 0x00007ffff5c6ec80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#19 0x00007fffeda276ba in start_thread (arg=0x7fffc2099700) at pthread_create.c:333
#20 0x00007ffff56dd3dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

@swframe
Copy link
Author

swframe commented Aug 28, 2017

#185

@swframe swframe closed this as completed Aug 28, 2017
@gineshidalgo99
Copy link
Member

Added the #185 fix to OpenPose

@gineshidalgo99 gineshidalgo99 added the help wanted/question Extra attention is needed label Aug 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted/question Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants