Skip to content

Commit d60f34a

Browse files
842974287facebook-github-bot
authored andcommitted
Back out "Convert multipy embedded library exceptions to specific exception type" (#320)
Summary: Pull Request resolved: #320 X-link: pytorch/torchrec#1153 Original commit changeset: 9cb3d1f17f54 Original Phabricator Diff: D44477860 In deploy, we do dlopen to link the .so each time when we create interpreter. So when interpreter manager is out of scope, we dlclose so we no longer have any symbols in the interpreter .so lib https://fburl.com/code/wlcp3r9o. If we throw a custom exception class that defined in interpreter .so, then in the catch block, if interpreter manager goes out of scope, we don't recognize this exception class anymore and lead to a crash. Reviewed By: zyan0 Differential Revision: D45629261 fbshipit-source-id: 5606f527e0952ee8a4184de25bd18b42faf772f3
1 parent c838637 commit d60f34a

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

multipy/runtime/Exception.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
// This source code is licensed under the BSD-style license found in the
55
// LICENSE file in the root directory of this source tree.
66

7-
#pragma once
8-
97
#ifndef MULTIPY_EXCEPTION_H
108
#define MULTIPY_EXCEPTION_H
119

1210
#include <exception>
13-
#include <stdexcept>
1411

1512
#define MULTIPY_INTERNAL_ASSERT_WITH_MESSAGE(condition, message) \
1613
if (!(condition)) { \
@@ -54,13 +51,3 @@
5451
MULTIPY_CHECK_NO_MESSAGE(__VA_ARGS__));
5552

5653
#endif // MULTIPY_EXCEPTION_H
57-
58-
namespace torch {
59-
namespace deploy {
60-
class MultipyEmbeddedException : public std::runtime_error {
61-
public:
62-
explicit MultipyEmbeddedException(const std::string& error)
63-
: std::runtime_error(error) {}
64-
};
65-
} // namespace deploy
66-
} // namespace torch

multipy/runtime/interpreter/interpreter_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ class MultiPySafeRethrow {
9292
auto code = err.value().attr("code").cast<int>();
9393
std::exit(code);
9494
}
95-
throw torch::deploy::MultipyEmbeddedException(
95+
throw std::runtime_error(
9696
std::string(file_) + ":" + std::to_string(line_) +
9797
": Exception Caught inside torch::deploy embedded library: \n" +
9898
err.what());
9999
} catch (std::exception& err) {
100-
throw torch::deploy::MultipyEmbeddedException(
100+
throw std::runtime_error(
101101
std::string(file_) + ":" + std::to_string(line_) +
102102
": Exception Caught inside torch::deploy embedded library: \n" +
103103
err.what());
104104
} catch (...) {
105-
throw torch::deploy::MultipyEmbeddedException(
105+
throw std::runtime_error(
106106
std::string(file_) + ":" + std::to_string(line_) +
107107
": Unknown Exception Caught inside torch::deploy embedded library");
108108
}

0 commit comments

Comments
 (0)