aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pdumper.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pdumper.c b/src/pdumper.c
index 7fabfa771ce..b19f206d1bd 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -1777,6 +1777,8 @@ dump_roots (struct dump_context *ctx)
1777 visit_static_gc_roots (visitor); 1777 visit_static_gc_roots (visitor);
1778} 1778}
1779 1779
1780#define PDUMPER_MAX_OBJECT_SIZE 2048
1781
1780static dump_off 1782static dump_off
1781field_relpos (const void *in_start, const void *in_field) 1783field_relpos (const void *in_start, const void *in_field)
1782{ 1784{
@@ -1784,7 +1786,15 @@ field_relpos (const void *in_start, const void *in_field)
1784 ptrdiff_t in_field_val = (ptrdiff_t) in_field; 1786 ptrdiff_t in_field_val = (ptrdiff_t) in_field;
1785 eassert (in_start_val <= in_field_val); 1787 eassert (in_start_val <= in_field_val);
1786 ptrdiff_t relpos = in_field_val - in_start_val; 1788 ptrdiff_t relpos = in_field_val - in_start_val;
1787 eassert (relpos < 1024); /* Sanity check. */ 1789 /* The following assertion attempts to detect bugs whereby IN_START
1790 and IN_FIELD don't point to the same object/structure, on the
1791 assumption that a too-large difference between them is
1792 suspicious. As of Apr 2019 the largest object we dump -- 'struct
1793 buffer' -- is slightly smaller than 1KB, and we want to leave
1794 some margin for future extensions. If the assertion below is
1795 ever violated, make sure the two pointers indeed point into the
1796 same object, and if so, enlarge the value of PDUMPER_MAX_OBJECT_SIZE. */
1797 eassert (relpos < PDUMPER_MAX_OBJECT_SIZE);
1788 return (dump_off) relpos; 1798 return (dump_off) relpos;
1789} 1799}
1790 1800