0001-disable-exceptions.patch 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. diff --git a/thirdparty/embree/common/algorithms/parallel_reduce.h b/thirdparty/embree/common/algorithms/parallel_reduce.h
  2. index b52b1e2e13..fbff38f660 100644
  3. --- a/thirdparty/embree/common/algorithms/parallel_reduce.h
  4. +++ b/thirdparty/embree/common/algorithms/parallel_reduce.h
  5. @@ -58,15 +58,15 @@ namespace embree
  6. const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
  7. [&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },
  8. reduction,context);
  9. - if (context.is_group_execution_cancelled())
  10. - throw std::runtime_error("task cancelled");
  11. + //if (context.is_group_execution_cancelled())
  12. + // throw std::runtime_error("task cancelled");
  13. return v;
  14. #else
  15. const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
  16. [&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },
  17. reduction);
  18. - if (tbb::task::self().is_cancelled())
  19. - throw std::runtime_error("task cancelled");
  20. + //if (tbb::task::self().is_cancelled())
  21. + // throw std::runtime_error("task cancelled");
  22. return v;
  23. #endif
  24. #else // TASKING_PPL
  25. diff --git a/thirdparty/embree/common/lexers/stringstream.cpp b/thirdparty/embree/common/lexers/stringstream.cpp
  26. index 42ffb10176..fa4266d0b9 100644
  27. --- a/thirdparty/embree/common/lexers/stringstream.cpp
  28. +++ b/thirdparty/embree/common/lexers/stringstream.cpp
  29. @@ -39,7 +39,10 @@ namespace embree
  30. std::vector<char> str; str.reserve(64);
  31. while (cin->peek() != EOF && !isSeparator(cin->peek())) {
  32. int c = cin->get();
  33. - if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
  34. + //if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
  35. + if (!isValidChar(c)) {
  36. + abort();
  37. + }
  38. str.push_back((char)c);
  39. }
  40. str.push_back(0);
  41. diff --git a/thirdparty/embree/common/sys/alloc.cpp b/thirdparty/embree/common/sys/alloc.cpp
  42. index de225fafc6..8e83646031 100644
  43. --- a/thirdparty/embree/common/sys/alloc.cpp
  44. +++ b/thirdparty/embree/common/sys/alloc.cpp
  45. @@ -24,16 +24,28 @@ namespace embree
  46. void enableUSMAllocEmbree(sycl::context* context, sycl::device* device)
  47. {
  48. - if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
  49. - if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
  50. + //if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
  51. + //if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
  52. + if (tls_context_embree != nullptr) {
  53. + abort();
  54. + }
  55. + if (tls_device_embree != nullptr) {
  56. + abort();
  57. + }
  58. tls_context_embree = context;
  59. tls_device_embree = device;
  60. }
  61. void disableUSMAllocEmbree()
  62. {
  63. - if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
  64. - if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
  65. + //if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
  66. + //if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
  67. + if (tls_context_embree == nullptr) {
  68. + abort();
  69. + }
  70. + if (tls_device_embree == nullptr) {
  71. + abort();
  72. + }
  73. tls_context_embree = nullptr;
  74. tls_device_embree = nullptr;
  75. }
  76. @@ -48,8 +60,14 @@ namespace embree
  77. void disableUSMAllocTutorial()
  78. {
  79. - if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
  80. - if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
  81. + //if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
  82. + //if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
  83. + if (tls_context_tutorial == nullptr) {
  84. + abort();
  85. + }
  86. + if (tls_device_tutorial == nullptr) {
  87. + abort();
  88. + }
  89. tls_context_tutorial = nullptr;
  90. tls_device_tutorial = nullptr;
  91. @@ -64,8 +82,11 @@ namespace embree
  92. assert((align & (align-1)) == 0);
  93. void* ptr = _mm_malloc(size,align);
  94. - if (size != 0 && ptr == nullptr)
  95. - throw std::bad_alloc();
  96. + //if (size != 0 && ptr == nullptr)
  97. + // throw std::bad_alloc();
  98. + if (size != 0 && ptr == nullptr) {
  99. + abort();
  100. + }
  101. return ptr;
  102. }
  103. @@ -94,8 +115,11 @@ namespace embree
  104. else
  105. ptr = sycl::aligned_alloc_shared(align,size,*device,*context);
  106. - if (size != 0 && ptr == nullptr)
  107. - throw std::bad_alloc();
  108. + //if (size != 0 && ptr == nullptr)
  109. + // throw std::bad_alloc();
  110. + if (size != 0 && ptr == nullptr) {
  111. + abort();
  112. + }
  113. return ptr;
  114. }
  115. @@ -241,7 +265,10 @@ namespace embree
  116. /* fall back to 4k pages */
  117. int flags = MEM_COMMIT | MEM_RESERVE;
  118. char* ptr = (char*) VirtualAlloc(nullptr,bytes,flags,PAGE_READWRITE);
  119. - if (ptr == nullptr) throw std::bad_alloc();
  120. + //if (ptr == nullptr) throw std::bad_alloc();
  121. + if (ptr == nullptr) {
  122. + abort();
  123. + }
  124. hugepages = false;
  125. return ptr;
  126. }
  127. @@ -257,8 +284,11 @@ namespace embree
  128. if (bytesNew >= bytesOld)
  129. return bytesOld;
  130. - if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
  131. - throw std::bad_alloc();
  132. + //if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
  133. + // throw std::bad_alloc();
  134. + if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT)) {
  135. + abort();
  136. + }
  137. return bytesNew;
  138. }
  139. @@ -268,8 +298,11 @@ namespace embree
  140. if (bytes == 0)
  141. return;
  142. - if (!VirtualFree(ptr,0,MEM_RELEASE))
  143. - throw std::bad_alloc();
  144. + //if (!VirtualFree(ptr,0,MEM_RELEASE))
  145. + // throw std::bad_alloc();
  146. + if (!VirtualFree(ptr,0,MEM_RELEASE)) {
  147. + abort();
  148. + }
  149. }
  150. void os_advise(void *ptr, size_t bytes)
  151. @@ -373,7 +406,10 @@ namespace embree
  152. /* fallback to 4k pages */
  153. void* ptr = (char*) mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
  154. - if (ptr == MAP_FAILED) throw std::bad_alloc();
  155. + //if (ptr == MAP_FAILED) throw std::bad_alloc();
  156. + if (ptr == MAP_FAILED) {
  157. + abort();
  158. + }
  159. hugepages = false;
  160. /* advise huge page hint for THP */
  161. @@ -389,8 +425,11 @@ namespace embree
  162. if (bytesNew >= bytesOld)
  163. return bytesOld;
  164. - if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
  165. - throw std::bad_alloc();
  166. + //if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
  167. + // throw std::bad_alloc();
  168. + if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1) {
  169. + abort();
  170. + }
  171. return bytesNew;
  172. }
  173. @@ -403,8 +442,11 @@ namespace embree
  174. /* for hugepages we need to also align the size */
  175. const size_t pageSize = hugepages ? PAGE_SIZE_2M : PAGE_SIZE_4K;
  176. bytes = (bytes+pageSize-1) & ~(pageSize-1);
  177. - if (munmap(ptr,bytes) == -1)
  178. - throw std::bad_alloc();
  179. + //if (munmap(ptr,bytes) == -1)
  180. + // throw std::bad_alloc();
  181. + if (munmap(ptr,bytes) == -1) {
  182. + abort();
  183. + }
  184. }
  185. /* hint for transparent huge pages (THP) */
  186. diff --git a/thirdparty/embree/common/sys/alloc.h b/thirdparty/embree/common/sys/alloc.h
  187. index e19c2c221a..e2c942049a 100644
  188. --- a/thirdparty/embree/common/sys/alloc.h
  189. +++ b/thirdparty/embree/common/sys/alloc.h
  190. @@ -160,7 +160,8 @@ namespace embree
  191. typedef std::ptrdiff_t difference_type;
  192. __forceinline pointer allocate( size_type n ) {
  193. - throw std::runtime_error("no allocation supported");
  194. + //throw std::runtime_error("no allocation supported");
  195. + abort();
  196. }
  197. __forceinline void deallocate( pointer p, size_type n ) {
  198. diff --git a/thirdparty/embree/common/sys/platform.h b/thirdparty/embree/common/sys/platform.h
  199. index 6dc0cf3318..9f08cd1516 100644
  200. --- a/thirdparty/embree/common/sys/platform.h
  201. +++ b/thirdparty/embree/common/sys/platform.h
  202. @@ -213,11 +213,15 @@
  203. #define UPRINT4(x,y,z,w) embree_cout_uniform << STRING(x) << " = " << (x) << ", " << STRING(y) << " = " << (y) << ", " << STRING(z) << " = " << (z) << ", " << STRING(w) << " = " << (w) << embree_endl
  204. #if defined(DEBUG) // only report file and line in debug mode
  205. + //#define THROW_RUNTIME_ERROR(str) \
  206. + // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
  207. #define THROW_RUNTIME_ERROR(str) \
  208. - throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
  209. + printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
  210. #else
  211. + //#define THROW_RUNTIME_ERROR(str) \
  212. + // throw std::runtime_error(str);
  213. #define THROW_RUNTIME_ERROR(str) \
  214. - throw std::runtime_error(str);
  215. + abort();
  216. #endif
  217. #define FATAL(x) THROW_RUNTIME_ERROR(x)
  218. diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
  219. index 83ead95122..e89ae04f8b 100644
  220. --- a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
  221. +++ b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
  222. @@ -48,13 +48,13 @@ namespace embree
  223. {
  224. Task* prevTask = thread.task;
  225. thread.task = this;
  226. - try {
  227. - if (context->cancellingException == nullptr)
  228. + //try {
  229. + // if (context->cancellingException == nullptr)
  230. closure->execute();
  231. - } catch (...) {
  232. - if (context->cancellingException == nullptr)
  233. - context->cancellingException = std::current_exception();
  234. - }
  235. + //} catch (...) {
  236. + // if (context->cancellingException == nullptr)
  237. + // context->cancellingException = std::current_exception();
  238. + //}
  239. thread.task = prevTask;
  240. add_dependencies(-1);
  241. }
  242. diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.h b/thirdparty/embree/common/tasking/taskschedulerinternal.h
  243. index b01bebf7c3..4a04323b80 100644
  244. --- a/thirdparty/embree/common/tasking/taskschedulerinternal.h
  245. +++ b/thirdparty/embree/common/tasking/taskschedulerinternal.h
  246. @@ -130,8 +130,11 @@ namespace embree
  247. __forceinline void* alloc(size_t bytes, size_t align = 64)
  248. {
  249. size_t ofs = bytes + ((align - stackPtr) & (align-1));
  250. - if (stackPtr + ofs > CLOSURE_STACK_SIZE)
  251. - throw std::runtime_error("closure stack overflow");
  252. + //if (stackPtr + ofs > CLOSURE_STACK_SIZE)
  253. + // throw std::runtime_error("closure stack overflow");
  254. + if (stackPtr + ofs > CLOSURE_STACK_SIZE) {
  255. + abort();
  256. + }
  257. stackPtr += ofs;
  258. return &stack[stackPtr-bytes];
  259. }
  260. @@ -139,8 +142,11 @@ namespace embree
  261. template<typename Closure>
  262. __forceinline void push_right(Thread& thread, const size_t size, const Closure& closure, TaskGroupContext* context)
  263. {
  264. - if (right >= TASK_STACK_SIZE)
  265. - throw std::runtime_error("task stack overflow");
  266. + //if (right >= TASK_STACK_SIZE)
  267. + // throw std::runtime_error("task stack overflow");
  268. + if (right >= TASK_STACK_SIZE) {
  269. + abort();
  270. + }
  271. /* allocate new task on right side of stack */
  272. size_t oldStackPtr = stackPtr;
  273. diff --git a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
  274. index 40f9043736..7ea9736c5c 100644
  275. --- a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
  276. +++ b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
  277. @@ -150,7 +150,8 @@ namespace embree
  278. }
  279. }
  280. else {
  281. - throw std::runtime_error("not supported node type in bvh_statistics");
  282. + //throw std::runtime_error("not supported node type in bvh_statistics");
  283. + abort();
  284. }
  285. return s;
  286. }
  287. diff --git a/thirdparty/embree/kernels/common/alloc.h b/thirdparty/embree/kernels/common/alloc.h
  288. index 2bd292de4d..8ac22e53ec 100644
  289. --- a/thirdparty/embree/kernels/common/alloc.h
  290. +++ b/thirdparty/embree/kernels/common/alloc.h
  291. @@ -189,8 +189,11 @@ namespace embree
  292. , atype(osAllocation ? EMBREE_OS_MALLOC : ALIGNED_MALLOC)
  293. , primrefarray(device,0)
  294. {
  295. - if (osAllocation && useUSM)
  296. - throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
  297. + //if (osAllocation && useUSM)
  298. + // throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
  299. + if (osAllocation && useUSM) {
  300. + abort();
  301. + }
  302. for (size_t i=0; i<MAX_THREAD_USED_BLOCK_SLOTS; i++)
  303. {
  304. @@ -502,8 +505,11 @@ namespace embree
  305. Block* myUsedBlocks = threadUsedBlocks[slot];
  306. if (myUsedBlocks) {
  307. void* ptr = myUsedBlocks->malloc(device,bytes,align,partial);
  308. - if (ptr == nullptr && !blockAllocation)
  309. - throw std::bad_alloc();
  310. + //if (ptr == nullptr && !blockAllocation)
  311. + // throw std::bad_alloc();
  312. + if (ptr == nullptr && !blockAllocation) {
  313. + abort();
  314. + }
  315. if (ptr) return ptr;
  316. }
  317. diff --git a/thirdparty/embree/kernels/common/rtcore.cpp b/thirdparty/embree/kernels/common/rtcore.cpp
  318. index 8dc5d7045b..e19c243bf6 100644
  319. --- a/thirdparty/embree/kernels/common/rtcore.cpp
  320. +++ b/thirdparty/embree/kernels/common/rtcore.cpp
  321. @@ -257,10 +257,15 @@ RTC_NAMESPACE_BEGIN;
  322. RTC_TRACE(rtcSetSceneBuildQuality);
  323. RTC_VERIFY_HANDLE(hscene);
  324. RTC_ENTER_DEVICE(hscene);
  325. + //if (quality != RTC_BUILD_QUALITY_LOW &&
  326. + // quality != RTC_BUILD_QUALITY_MEDIUM &&
  327. + // quality != RTC_BUILD_QUALITY_HIGH)
  328. + // throw std::runtime_error("invalid build quality");
  329. if (quality != RTC_BUILD_QUALITY_LOW &&
  330. quality != RTC_BUILD_QUALITY_MEDIUM &&
  331. - quality != RTC_BUILD_QUALITY_HIGH)
  332. - throw std::runtime_error("invalid build quality");
  333. + quality != RTC_BUILD_QUALITY_HIGH) {
  334. + abort();
  335. + }
  336. scene->setBuildQuality(quality);
  337. RTC_CATCH_END2(scene);
  338. }
  339. @@ -1563,11 +1568,17 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
  340. RTC_TRACE(rtcSetGeometryBuildQuality);
  341. RTC_VERIFY_HANDLE(hgeometry);
  342. RTC_ENTER_DEVICE(hgeometry);
  343. + //if (quality != RTC_BUILD_QUALITY_LOW &&
  344. + // quality != RTC_BUILD_QUALITY_MEDIUM &&
  345. + // quality != RTC_BUILD_QUALITY_HIGH &&
  346. + // quality != RTC_BUILD_QUALITY_REFIT)
  347. + // throw std::runtime_error("invalid build quality");
  348. if (quality != RTC_BUILD_QUALITY_LOW &&
  349. quality != RTC_BUILD_QUALITY_MEDIUM &&
  350. quality != RTC_BUILD_QUALITY_HIGH &&
  351. - quality != RTC_BUILD_QUALITY_REFIT)
  352. - throw std::runtime_error("invalid build quality");
  353. + quality != RTC_BUILD_QUALITY_REFIT) {
  354. + abort();
  355. + }
  356. geometry->setBuildQuality(quality);
  357. RTC_CATCH_END2(geometry);
  358. }
  359. diff --git a/thirdparty/embree/kernels/common/rtcore.h b/thirdparty/embree/kernels/common/rtcore.h
  360. index 73a061de11..cd7a6f4395 100644
  361. --- a/thirdparty/embree/kernels/common/rtcore.h
  362. +++ b/thirdparty/embree/kernels/common/rtcore.h
  363. @@ -13,7 +13,7 @@ namespace embree
  364. __forceinline bool isIncoherent(RTCRayQueryFlags flags) { return (flags & RTC_RAY_QUERY_FLAG_COHERENT) == RTC_RAY_QUERY_FLAG_INCOHERENT; }
  365. /*! Macros used in the rtcore API implementation */
  366. -#if 0
  367. +#if 1
  368. # define RTC_CATCH_BEGIN
  369. # define RTC_CATCH_END(device)
  370. # define RTC_CATCH_END2(scene)
  371. @@ -94,6 +94,7 @@ namespace embree
  372. #define RTC_TRACE(x)
  373. #endif
  374. +#if 0
  375. /*! used to throw embree API errors */
  376. struct rtcore_error : public std::exception
  377. {
  378. @@ -109,13 +110,16 @@ namespace embree
  379. RTCError error;
  380. std::string str;
  381. };
  382. +#endif
  383. #if defined(DEBUG) // only report file and line in debug mode
  384. #define throw_RTCError(error,str) \
  385. - throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
  386. + printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
  387. + //throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
  388. #else
  389. #define throw_RTCError(error,str) \
  390. - throw rtcore_error(error,str);
  391. + abort();
  392. + //throw rtcore_error(error,str);
  393. #endif
  394. #define RTC_BUILD_ARGUMENTS_HAS(settings,member) \
  395. diff --git a/thirdparty/embree/kernels/common/scene.cpp b/thirdparty/embree/kernels/common/scene.cpp
  396. index fda8dd938a..706cc512df 100644
  397. --- a/thirdparty/embree/kernels/common/scene.cpp
  398. +++ b/thirdparty/embree/kernels/common/scene.cpp
  399. @@ -894,16 +894,16 @@ namespace embree
  400. }
  401. /* initiate build */
  402. - try {
  403. + //try {
  404. TaskScheduler::TaskGroupContext context;
  405. scheduler->spawn_root([&]() { commit_task(); Lock<MutexSys> lock(taskGroup->schedulerMutex); taskGroup->scheduler = nullptr; }, &context, 1, !join);
  406. - }
  407. - catch (...) {
  408. - accels_clear();
  409. - Lock<MutexSys> lock(taskGroup->schedulerMutex);
  410. - taskGroup->scheduler = nullptr;
  411. - throw;
  412. - }
  413. + //}
  414. + //catch (...) {
  415. + // accels_clear();
  416. + // Lock<MutexSys> lock(taskGroup->schedulerMutex);
  417. + // taskGroup->scheduler = nullptr;
  418. + // throw;
  419. + //}
  420. }
  421. #endif
  422. diff --git a/thirdparty/embree/kernels/common/state.cpp b/thirdparty/embree/kernels/common/state.cpp
  423. index 4e3ab6ddfb..8e83c95bd7 100644
  424. --- a/thirdparty/embree/kernels/common/state.cpp
  425. +++ b/thirdparty/embree/kernels/common/state.cpp
  426. @@ -194,13 +194,13 @@ namespace embree
  427. bool State::parseFile(const FileName& fileName)
  428. {
  429. Ref<Stream<int> > file;
  430. - try {
  431. + //try {
  432. file = new FileStream(fileName);
  433. - }
  434. - catch (std::runtime_error& e) {
  435. - (void) e;
  436. - return false;
  437. - }
  438. + //}
  439. + //catch (std::runtime_error& e) {
  440. + // (void) e;
  441. + // return false;
  442. + //}
  443. std::vector<std::string> syms;
  444. for (size_t i=0; i<sizeof(symbols)/sizeof(void*); i++)