Repository: pytorch/audio

Issue #54: Segmentation fault (core dumped)
Created: 2018-07-03T12:01:29Z
I'm unable to load any file after first time installation. I faced an issue #53 which I somehow resolved by modifying setup.py file, but am not sure if it is the correct way...
OS: " CentOS Linux release 7.2.1511 (Core)"
[1]: import torchaudio
[2]: torchaudio.load('speech-data/can-you-get-it.wav')
Segmentation fault (core dumped)

Duplicate issue #65: Trying to load corrupt file segfaults instead of raising exception.
Created: 2018-11-09T01:45:01Z
The problem
Trying to load an invalid file segfaults and crashes the entire process instead of raising an exception.
Steps to reproduce
$ touch test.mp3
$ python -c "import torchaudio; torchaudio.load('test.mp3')"
/home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
formats: can't open input file `test.mp3': Invalid argument
[1]    27224 segmentation fault (core dumped)  python -c "import torchaudio; torchaudio.load('test.mp3')"
GDB Backtrace
/home/kpar/.pyenv/versions/3.7.0/envs/foley/lib/python3.7/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py:47: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
formats: can't open input file `test.mp3': Invalid argument

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007fffa92e0cb9 in sox_close () from /usr/lib/x86_64-linux-gnu/libsox.so.3
(gdb) bt
#0  0x00007fffa92e0cb9 in sox_close () from /usr/lib/x86_64-linux-gnu/libsox.so.3
#1  0x00007fffa955da1c in torch::audio::(anonymous namespace)::SoxDescriptor::~SoxDescriptor (this=0x7fffffffd368, __in_chrg=<optimized out>) at torchaudio/torch_sox.cpp:21
#2  torch::audio::read_audio_file (file_name=..., output=..., nframes=<optimized out>, offset=<optimized out>) at torchaudio/torch_sox.cpp:83
#3  0x00007fffa956b291 in pybind11::detail::argument_loader<std::string const&, at::Tensor, long, long>::call_impl<int, int (*&)(std::string const&, at::Tensor, long, long), 0ul, 1ul, 2ul, 3ul, pybind11::detail::void_type> (f=<optimized out>, this=0x7fffffffd3c0) at /home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/torch/lib/include/pybind11/cast.h:1919
#4  pybind11::detail::argument_loader<std::string const&, at::Tensor, long, long>::call<int, pybind11::detail::void_type, int (*&)(std::string const&, at::Tensor, long, long)>(int (*&)(std::string const&, at::Tensor, long, long)) && (f=<optimized out>, this=<optimized out>) at /home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/torch/lib/include/pybind11/cast.h:1896
#5  void pybind11::cpp_function::initialize<int (*&)(std::string const&, at::Tensor, long, long), int, std::string const&, at::Tensor, long, long, pybind11::name, pybind11::scope, pybind11::sibling, char [34]>(int (*&)(std::string const&, at::Tensor, long, long), int (*)(std::string const&, at::Tensor, long, long), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, char const (&) [34])::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const (call=..., __closure=0x0)
    at /home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/torch/lib/include/pybind11/pybind11.h:154
#6  void pybind11::cpp_function::initialize<int (*&)(std::string const&, at::Tensor, long, long), int, std::string const&, at::Tensor, long, long, pybind11::name, pybind11::scope, pybind11::sibling, char [34]>(int (*&)(std::string const&, at::Tensor, long, long), int (*)(std::string const&, at::Tensor, long, long), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&, char const (&) [34])::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) () at /home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/torch/lib/include/pybind11/pybind11.h:132
#7  0x00007fffa9568875 in pybind11::cpp_function::dispatcher (self=self@entry=0x7ffff7e44990, args_in=args_in@entry=0x7ffff7f04278, kwargs_in=kwargs_in@entry=0x0)
    at /home/kpar/.pyenv/versions/foley/lib/python3.7/site-packages/torch/lib/include/pybind11/pybind11.h:619
#8  0x00005555555c9f57 in _PyMethodDef_RawFastCallKeywords (kwnames=0x0, nargs=140737352321424, args=0x4574c92a0000000c, self=0x7ffff7e44990, method=0x555556aeaef0) at Objects/call.c:690
#9  _PyCFunction_FastCallKeywords (func=func@entry=0x7fffa98ab120, args=args@entry=0x555555b42630, nargs=nargs@entry=4, kwnames=kwnames@entry=0x0) at Objects/call.c:730
#10 0x00005555555b6c4e in call_function (kwnames=0x0, oparg=4, pp_stack=<synthetic pointer>) at Python/ceval.c:4547
#11 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3086
#12 0x0000555555686e0d in PyEval_EvalFrameEx (throwflag=0, f=0x555555b42488) at Python/ceval.c:547
#13 _PyEval_EvalCodeWithName (_co=0x7ffff7e55300, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=1, kwnames=0x0, kwargs=0x7ffff7f86b78, kwcount=0, kwstep=1,
    defs=0x7ffff7e63ce0, defcount=4, kwdefs=0x0, closure=0x0, name=0x7ffff7f43538, qualname=0x7ffff7f43538) at Python/ceval.c:3923
#14 0x00005555555c9386 in _PyFunction_FastCallKeywords (func=<optimized out>, stack=<optimized out>, nargs=<optimized out>, kwnames=<optimized out>) at Objects/call.c:433
#15 0x00005555555b6d6b in call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>) at Python/ceval.c:4586
#16 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3086
#17 0x0000555555686e0d in PyEval_EvalFrameEx (throwflag=0, f=0x7ffff7f869f8) at Python/ceval.c:547
#18 _PyEval_EvalCodeWithName (_co=_co@entry=0x7ffff7f136f0, globals=globals@entry=0x7ffff7eda0d8, locals=locals@entry=0x7ffff7eda0d8, args=args@entry=0x0, argcount=argcount@entry=0,
    kwnames=kwnames@entry=0x0, kwargs=0x0, kwcount=0, kwstep=2, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at Python/ceval.c:3923
#19 0x0000555555686f43 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=locals@entry=0x7ffff7eda0d8,
    globals=globals@entry=0x7ffff7eda0d8, _co=_co@entry=0x7ffff7f136f0) at Python/ceval.c:3952
#20 PyEval_EvalCode (co=co@entry=0x7ffff7f136f0, globals=globals@entry=0x7ffff7eda0d8, locals=locals@entry=0x7ffff7eda0d8) at Python/ceval.c:524
#21 0x00005555556c021e in run_mod (arena=0x7ffff7fd4078, flags=0x7ffff7e4eed0, locals=0x7ffff7eda0d8, globals=0x7ffff7eda0d8, filename=0x7ffff7f14e30, mod=<optimized out>) at Python/pythonrun.c:1035
#22 PyRun_StringFlags (flags=0x7ffff7e4eed0, locals=0x7ffff7eda0d8, globals=0x7ffff7eda0d8, start=257, str=0x7ffff7f040a0 "import torchaudio; torchaudio.load('test.mp3')\n") at Python/pythonrun.c:959
#23 PyRun_SimpleStringFlags (command=0x7ffff7f040a0 "import torchaudio; torchaudio.load('test.mp3')\n", flags=flags@entry=0x7fffffffdca0) at Python/pythonrun.c:455
#24 0x00005555555bb250 in pymain_run_command (cf=0x7fffffffdca0, command=<optimized out>) at Modules/main.c:383
#25 pymain_run_python (pymain=0x7fffffffddf0) at Modules/main.c:2514
#26 pymain_main (pymain=pymain@entry=0x7fffffffddf0) at Modules/main.c:2662
#27 0x00005555555bcccb in _Py_UnixMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:2697
#28 0x00007ffff7041b97 in __libc_start_main (main=0x5555555ae620 <main>, argc=3, argv=0x7fffffffe028, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe018)
    at ../csu/libc-start.c:310
#29 0x00005555555b825a in _start ()
(gdb)

Closing comment (2018-11-09T01:48:13Z): Actually this seems like a duplicate of #54. I'll close this and move it over tehre.