0006-node-fix-undefined-behaviour-leading-to-broken-code-with-GCC-6.patch 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Mon, 9 May 2016 16:21:57 +0200
  3. Subject: node: fix undefined behaviour leading to broken code with GCC 6
  4. Fixes segfaults occuring in the node host build when GCC 6 is used.
  5. Backport of upstream commit 96198d5bc710a4e3ca49eeeb3b3fa7b8cb61547d.
  6. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  7. diff --git a/lang/node/patches/004-gcc6-undefined-behaviour.patch b/lang/node/patches/004-gcc6-undefined-behaviour.patch
  8. new file mode 100644
  9. index 0000000000000000000000000000000000000000..dbbbcf0c54bb62f643521411668772531d42b89a
  10. --- /dev/null
  11. +++ b/lang/node/patches/004-gcc6-undefined-behaviour.patch
  12. @@ -0,0 +1,64 @@
  13. +diff --git a/deps/v8/src/heap/incremental-marking.cc b/deps/v8/src/heap/incremental-marking.cc
  14. +index c922e83..2ead8be 100644
  15. +--- a/deps/v8/src/heap/incremental-marking.cc
  16. ++++ b/deps/v8/src/heap/incremental-marking.cc
  17. +@@ -379,7 +379,7 @@ void IncrementalMarking::DeactivateIncrementalWriteBarrier() {
  18. + DeactivateIncrementalWriteBarrierForSpace(heap_->new_space());
  19. +
  20. + LargePage* lop = heap_->lo_space()->first_page();
  21. +- while (lop->is_valid()) {
  22. ++ while (LargePage::IsValid(lop)) {
  23. + SetOldSpacePageFlags(lop, false, false);
  24. + lop = lop->next_page();
  25. + }
  26. +@@ -414,7 +414,7 @@ void IncrementalMarking::ActivateIncrementalWriteBarrier() {
  27. + ActivateIncrementalWriteBarrier(heap_->new_space());
  28. +
  29. + LargePage* lop = heap_->lo_space()->first_page();
  30. +- while (lop->is_valid()) {
  31. ++ while (LargePage::IsValid(lop)) {
  32. + SetOldSpacePageFlags(lop, true, is_compacting_);
  33. + lop = lop->next_page();
  34. + }
  35. +diff --git a/deps/v8/src/heap/spaces-inl.h b/deps/v8/src/heap/spaces-inl.h
  36. +index 56c2bad..1a45096 100644
  37. +--- a/deps/v8/src/heap/spaces-inl.h
  38. ++++ b/deps/v8/src/heap/spaces-inl.h
  39. +@@ -148,7 +148,7 @@ Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable,
  40. +
  41. + bool PagedSpace::Contains(Address addr) {
  42. + Page* p = Page::FromAddress(addr);
  43. +- if (!p->is_valid()) return false;
  44. ++ if (!Page::IsValid(p)) return false;
  45. + return p->owner() == this;
  46. + }
  47. +
  48. +diff --git a/deps/v8/src/heap/spaces.cc b/deps/v8/src/heap/spaces.cc
  49. +index e197f5a..2fe10eb 100644
  50. +--- a/deps/v8/src/heap/spaces.cc
  51. ++++ b/deps/v8/src/heap/spaces.cc
  52. +@@ -2918,7 +2918,7 @@ LargePage* LargeObjectSpace::FindPage(Address a) {
  53. + if (e != NULL) {
  54. + DCHECK(e->value != NULL);
  55. + LargePage* page = reinterpret_cast<LargePage*>(e->value);
  56. +- DCHECK(page->is_valid());
  57. ++ DCHECK(LargePage::IsValid(page));
  58. + if (page->Contains(a)) {
  59. + return page;
  60. + }
  61. +diff --git a/deps/v8/src/heap/spaces.h b/deps/v8/src/heap/spaces.h
  62. +index 312d75f..1054672 100644
  63. +--- a/deps/v8/src/heap/spaces.h
  64. ++++ b/deps/v8/src/heap/spaces.h
  65. +@@ -283,9 +283,9 @@ class MemoryChunk {
  66. + // Only works for addresses in pointer spaces, not data or code spaces.
  67. + static inline MemoryChunk* FromAnyPointerAddress(Heap* heap, Address addr);
  68. +
  69. +- Address address() { return reinterpret_cast<Address>(this); }
  70. ++ static bool IsValid(MemoryChunk* chunk) { return chunk != nullptr; }
  71. +
  72. +- bool is_valid() { return address() != NULL; }
  73. ++ Address address() { return reinterpret_cast<Address>(this); }
  74. +
  75. + MemoryChunk* next_chunk() const {
  76. + return reinterpret_cast<MemoryChunk*>(base::Acquire_Load(&next_chunk_));