Skip to content

Unit tests for throwing exceptions for C++ Vocab and Vectors classes results in seg faults #933

Open
@Nayef211

Description

@Nayef211

🐛 Bug

Describe the bug
Unit testing for runtime errors on experimental Vocab and Vectors classes fails due to segmentation faults. This only occurs for runtime errors that are thrown in the underlying C++ classes when using the pybind11 registration. Using the same class but registered with torchbind works fine.

To Reproduce
Steps to reproduce the behavior:

  1. Remove decorator to skip test_errors_vocab_cpp on Windows platform within test/experimental/test_vocab.py,
  2. Remove decorator to skip test_errors_vectors_cpp on Windows platform within test/experimental/test_vectors.py
  3. Run the tests with pytest

Expected behavior
Expect the errors thrown in cpp to be propagated to Python and caught by with self.assertRaises(RuntimeError):

Environment

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
python -c "import torchtext; print(\"torchtext version is \", torchtext.__version__)"
  • PyTorch Version (e.g., 1.0): 1.7.0a0+1978188
  • OS (e.g., Linux): Windows
  • How you installed PyTorch (conda, pip, source): source
  • Build command you used (if compiling from source):
  • Python version: Python 3.7.7
  • CUDA/cuDNN version: N/A

cc @peterjc123 @maxluk @nbcsm @guyang3532 @gunandrose4u @smartcat2010 @mszhanyi

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions