aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2019-04-03 20:41:47 +0300
committerEli Zaretskii2019-04-03 20:41:47 +0300
commit2bcf0f097cd6841af5844d3a2a9d670ba4daea99 (patch)
tree483bebb5497d04b98721099c216f86ad7a243283 /src
parentb29b79efd9752caf1e99273575a00b6769ddad56 (diff)
downloademacs-2bcf0f097cd6841af5844d3a2a9d670ba4daea99.tar.gz
emacs-2bcf0f097cd6841af5844d3a2a9d670ba4daea99.zip
Improve commentary in 'field_relpos'
* src/pdumper.c (PDUMPER_MAX_OBJECT_SIZE): New macro. (field_relpos): Use PDUMPER_MAX_OBJECT_SIZE, and comment on why we require that relpos be not too large.
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