Improve error message when registering empty bundles
Summary: This change lets `registerBundle(bundleId, file)` throw an exception when the file is empty, improving on the current behavior of an eventual SIGABRT saying "MAP_FAILED: Invalid argument" Reviewed By: ridiculousfish Differential Revision: D16451938 fbshipit-source-id: b8b2d0bfed476319c379122fad59a5bf0a8c813b
This commit is contained in:
Родитель
8b5ed7abdd
Коммит
691679a790
|
@ -110,6 +110,9 @@ static off_t maybeRemap(char *data, size_t size, int fd) {
|
||||||
#endif // WITH_FBREMAP
|
#endif // WITH_FBREMAP
|
||||||
|
|
||||||
const char *JSBigFileString::c_str() const {
|
const char *JSBigFileString::c_str() const {
|
||||||
|
if (m_size == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
if (!m_data) {
|
if (!m_data) {
|
||||||
m_data =
|
m_data =
|
||||||
(const char *) mmap(0, m_size, PROT_READ, MAP_PRIVATE, m_fd, m_mapOff);
|
(const char *) mmap(0, m_size, PROT_READ, MAP_PRIVATE, m_fd, m_mapOff);
|
||||||
|
|
|
@ -161,6 +161,10 @@ void JSIExecutor::registerBundle(
|
||||||
bundleRegistry_->registerBundle(bundleId, bundlePath);
|
bundleRegistry_->registerBundle(bundleId, bundlePath);
|
||||||
} else {
|
} else {
|
||||||
auto script = JSBigFileString::fromPath(bundlePath);
|
auto script = JSBigFileString::fromPath(bundlePath);
|
||||||
|
if (script->size() == 0) {
|
||||||
|
throw std::invalid_argument(
|
||||||
|
"Empty bundle registered with ID " + tag + " from " + bundlePath);
|
||||||
|
}
|
||||||
runtime_->evaluateJavaScript(
|
runtime_->evaluateJavaScript(
|
||||||
std::make_unique<BigStringBuffer>(std::move(script)),
|
std::make_unique<BigStringBuffer>(std::move(script)),
|
||||||
JSExecutor::getSyntheticBundlePath(bundleId, bundlePath));
|
JSExecutor::getSyntheticBundlePath(bundleId, bundlePath));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче