Re: [HarfBuzz] HB_CLOSURE_MAX_STAGES (was: harfbuzz: Branch 'master')
On Mon, Jul 30, 2018 at 6:21 PM, Richard Wordingham < richard.wording...@ntlworld.com> wrote: > On Mon, 30 Jul 2018 17:04:42 -0700 > Behdad Esfahbod wrote: > > > On Thu, Jul 26, 2018 at 12:06 AM, Richard Wordingham < > > richard.wording...@ntlworld.com> wrote: > > > > > On Tue, 24 Jul 2018 16:31:50 + (UTC) > > > beh...@kemper.freedesktop.org (Behdad Esfahbod) wrote: > > > > > > The following change bothers me: > > > > > > > src/hb-ot-layout-common-private.hh |7 +++ > > > > src/hb-ot-layout.cc|5 - > > > > 2 files changed, 11 insertions(+), 1 deletion(-) > > > > > > > > New commits: > > > > commit 85646fdadb2f102333485e07425361795b4e0412 > > > > Author: Garret Rieger > > > > Date: Mon Jul 23 15:37:18 2018 -0700 > > > > > > > > [subset] Limit the iterations of the closure algorithm. > > > > Prevents O(n^2) run times. > > > > > > > > diff --git a/src/hb-ot-layout-common-private.hh > > > > b/src/hb-ot-layout-common-private.hh index 21caf9e9..7ff0dbeb > > > > 100644 --- a/src/hb-ot-layout-common-private.hh > > > > +++ b/src/hb-ot-layout-common-private.hh > > > > @@ -41,6 +41,13 @@ > > > > #ifndef HB_MAX_CONTEXT_LENGTH > > > > #define HB_MAX_CONTEXT_LENGTH64 > > > > #endif > > > > +#ifndef HB_CLOSURE_MAX_STAGES > > > > +/* > > > > + * The maximum number of times a lookup can be applied during > > > > shaping. > > > > + * Used to limit the number of iterations of the closure > > > > algorithm. > > > > + */ > > > > +#define HB_CLOSURE_MAX_STAGES8 > > > > +#endif > > > > > > I presume that this is intended to prevent a denial of service > > > attack, > > > > Correct. > > > > > > > at the cost of trashing a subset font. > > > > > > > Not really. > > > > > > > In non-malicious use, how is the victim supposed to detect that and > > > then how he needs to change HarfBuzz or his font? Does he have to > > > read all the text using the subset font simply to detect a > > > problem? How does one test that a font does not hit this limit? > > > > > > It's impossible to hit that limit... Ok, it would be impossible if we > > increase it to 32. I'll do that. > > That'll probably work, but I'm now intrigued. Why have a limit that > will never be hit? Are you just catering for HarfBuzz's logic simply > going badly wrong in very unusual circumstances? > Yes, simply as defense against malicious fonts and how the subsetter's glyph-closure routine can be tricked to collect (way) more glyphs than shaper can actually reach. > > The further points is just nit-picking and can be safely ignored. > > > > Does one have to > > > iterate over the power set of the supported characters for each > > > script? That's O(2^n) - impossible to do! > > > > > > The description of HB_CLOSURE_MAX_STAGES is completely wrong. I was > > > initially alarmed because I have lookups that are invoked in more > > > than 8 places in substitution subtables. A more accurate, but > > > still not perfect, definition, would be 'the maximum number of > > > times lookup can change a bit of text'. > > > > > > > Nope. Stage is a technical term in HarfBuzz GSUB processing. > > > > According to OpenType spec, lookups are processed in increasing order > > of their indices. This implies that each lookup is processed one. > > But then the script shaping specs say some features are applied > > separately. Each of those separated list of features/lookups applied > > are called one stage. The total number of stages in any shaper is > > the total number of times a lookup can be applied in theory. > > That applies to lookups that are always formally unconditionally > applied. It doesn't apply to lookups invoked in response to context or > chaincontext lookups. > > > Note > > that this does NOT limit recursion through Context and ChainContext > > lookups. > > Richard. > ___ > HarfBuzz mailing list > HarfBuzz@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/harfbuzz > -- behdad http://behdad.org/ ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master'
NEWS|8 configure.ac|2 +- src/hb-ot-layout.cc |2 +- src/hb-version.h|4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) New commits: commit 44d1fb37efa20852cc466c0f0bba95dbd24ce288 Author: Behdad Esfahbod Date: Wed Aug 1 14:51:51 2018 -0700 1.8.5 diff --git a/NEWS b/NEWS index fce43a36..13aa6629 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Overview of changes leading to 1.8.5 +Wednesday, August 1, 2018 + +- Major Khmer shaper improvements to better match Microsoft. +- Indic bug fixes. +- Internal improvements to atomic operations. + + Overview of changes leading to 1.8.4 Tuesday, July 17, 2018 diff --git a/configure.ac b/configure.ac index 0dd70e68..c439f54d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], -[1.8.4], +[1.8.5], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 1cb0c3ad..c790c3ce 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -765,7 +765,7 @@ _hb_ot_layout_collect_features_languages (hb_face_t *face, /** * hb_ot_layout_collect_features: * - * Since: REPLACEME + * Since: 1.8.5 **/ void hb_ot_layout_collect_features (hb_face_t *face, diff --git a/src/hb-version.h b/src/hb-version.h index 09e3c2c0..c5092c78 100644 --- a/src/hb-version.h +++ b/src/hb-version.h @@ -38,9 +38,9 @@ HB_BEGIN_DECLS #define HB_VERSION_MAJOR 1 #define HB_VERSION_MINOR 8 -#define HB_VERSION_MICRO 4 +#define HB_VERSION_MICRO 5 -#define HB_VERSION_STRING "1.8.4" +#define HB_VERSION_STRING "1.8.5" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*1+(minor)*100+(micro) <= \ ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Changes to 'refs/tags/1.8.5'
Tag '1.8.5' created by Behdad Esfahbod at 2018-08-01 21:52 + 1.8.5 -BEGIN PGP SIGNATURE- iHAEABECADAWIQQid2UKTovf5Lf2vkGf7gTl01MRFQUCW2IrgxIcYmVoZGFkQGJl aGRhZC5vcmcACgkQn+4E5dNTERV6BACgsf+1FPESykThahOj8IQLWYL2laEAn3QW dtv3GLu9YK3X/AxSj74xGFOL =f0xB -END PGP SIGNATURE- Changes since 1.8.4-71: --- 0 files changed --- ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master' - 7 commits
appveyor.yml |1 docs/harfbuzz-sections.txt |1 src/hb-atomic-private.hh | 75 ++-- src/hb-ot-layout-common-private.hh | 14 -- src/hb-ot-layout.cc| 86 - src/hb-ot-layout.h |8 --- 6 files changed, 53 insertions(+), 132 deletions(-) New commits: commit 13f4c137c686aed5c2888b5c47d9f16892be0d5e Author: Behdad Esfahbod Date: Wed Aug 1 14:13:59 2018 -0700 [atomic] Fix Solaris ones to add proper barriers diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index 0e7a8414..0b043e69 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -62,7 +62,7 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) const void *O = O_; // Need lvalue return __atomic_compare_exchange_n ((void **) P, (void **) , (void *) N, true, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); } -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (_hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) #elif !defined(HB_NO_MT) && __cplusplus >= 201103L @@ -82,7 +82,7 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) const void *O = O_; // Need lvalue return reinterpret_cast *> (P)->compare_exchange_weak (O, N, std::memory_order_acq_rel, std::memory_order_relaxed); } -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (_hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N)) #elif !defined(HB_NO_MT) && (defined(_WIN32) || defined(__CYGWIN__)) @@ -127,9 +127,25 @@ typedef int hb_atomic_int_impl_t; #define _hb_memory_barrier() __machine_rw_barrier () typedef unsigned int hb_atomic_int_impl_t; -#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv ((AI), (V)) - (V) /* XXX barrier again? */) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false /* XXX barrier again? */) +static inline int _hb_fetch_and_add (hb_atomic_int_impl_t *AI, int V) +{ + _hb_memory_w_barrier (); + int result = atomic_add_int_nv (AI, V); + _hb_memory_r_barrier (); + return result; +} +static inline bool _hb_compare_and_swap_ptr (const void **P, const void *O, const void *N) +{ + _hb_memory_w_barrier (); + int result = atomic_cas_ptr ((void **) P, (void *) O, (void *) N) == (void *) O; + _hb_memory_r_barrier (); + return result; +} + +#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) + +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swap_ptr ((const void **) (P), (O), (N)) #elif !defined(HB_NO_MT) && defined(__APPLE__) @@ -161,25 +177,29 @@ typedef int32_t hb_atomic_int_impl_t; #include -static inline int _hb_fetch_and_add (int* AI, unsigned int V) { - __lwsync(); - int result = __fetch_and_add(AI, V); - __lwsync(); +#define _hb_memory_barrier() __lwsync () + +typedef int hb_atomic_int_impl_t; + +static inline int _hb_fetch_and_add (hb_atomic_int_impl_t *AI, int V) +{ + _hb_memory_barrier (); + int result = __fetch_and_add (AI, V); + _hb_memory_barrier (); return result; } -static inline int _hb_compare_and_swaplp (long* P, long O, long N) { - __lwsync(); - int result = __compare_and_swaplp (P, , N); - __lwsync(); +static inline bool _hb_compare_and_swaplp (long *P, long O, long N) +{ + _hb_memory_barrier (); + bool result = __compare_and_swaplp (P, , N); + _hb_memory_barrier (); return result; } -#define _hb_memory_barrier() __lwsync () - -typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N)) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long *) (P), (long) (O), (long) (N)) +static_assert ((sizeof (long) == sizeof (void *)), ""); #elif !defined(HB_NO_MT) commit 19dfaa351568887a74cee2c46d6acfcc3fa718ff Author: Behdad Esfahbod Date: Wed Aug 1 14:02:39 2018 -0700 [atomic] Remove volatile from IBM impl signature diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index 3239193a..0e7a8414 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -161,13 +161,13 @@ typedef int32_t hb_atomic_int_impl_t; #include -static inline int _hb_fetch_and_add(volatile int* AI, unsigned int V) { +static inline int _hb_fetch_and_add (int* AI, unsigned int V) { __lwsync(); int result = __fetch_and_add(AI, V); __lwsync(); return result; } -static
[HarfBuzz] harfbuzz: Branch 'master'
src/hb-atomic-private.hh |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit dfc86e4b35ffdeb8f73e83511712e75413bbb7d9 Author: Behdad Esfahbod Date: Wed Aug 1 00:22:18 2018 -0700 [atomic] Fix cast to fallback ptr_get() diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index f60c46e3..852b2242 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -229,7 +229,7 @@ struct hb_atomic_int_t }; -#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get(P) +#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get((void **) P) #define hb_atomic_ptr_cmpexch(P,O,N) hb_atomic_ptr_impl_cmpexch((P),(O),(N)) ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master'
src/hb-gobject-structs.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 7a4d576e81c4de68ea66b2d5fe7712e29d715272 Author: Behdad Esfahbod Date: Wed Aug 1 00:19:25 2018 -0700 [gobject] Fix copy/paste error diff --git a/src/hb-gobject-structs.h b/src/hb-gobject-structs.h index ccc06a5e..800beede 100644 --- a/src/hb-gobject-structs.h +++ b/src/hb-gobject-structs.h @@ -91,7 +91,7 @@ hb_gobject_set_get_type (void); HB_EXTERN GType hb_gobject_map_get_type (void); -#define HB_GOBJECT_TYPE_SET (hb_gobject_map_get_type ()) +#define HB_GOBJECT_TYPE_MAP (hb_gobject_map_get_type ()) HB_EXTERN GType hb_gobject_shape_plan_get_type (void); ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
src/hb-atomic-private.hh | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) New commits: commit ad275627425c9b3c4fb1e69aa408067bd0bb77da Author: Behdad Esfahbod Date: Tue Jul 31 23:01:05 2018 -0700 [atomic] On IBM, use light-weight sync for everything lwsync() is a full read/write-barrier. That's all we need, never need sync(). I'm not sure why an isync() was used in fetch_and_add, but since that's a read-modify-write, I just changed it to have lwsync() on both sides. diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index 0d0badfb..f60c46e3 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -163,20 +163,20 @@ static inline void _hb_memory_barrier (void) { OSMemoryBarrier (); } static inline int _hb_fetch_and_add(volatile int* AI, unsigned int V) { __lwsync(); int result = __fetch_and_add(AI, V); - __isync(); + __lwsync(); return result; } static inline int _hb_compare_and_swaplp(volatile long* P, long O, long N) { - __sync(); + __lwsync(); int result = __compare_and_swaplp (P, , N); - __sync(); + __lwsync(); return result; } typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V)) -static inline void _hb_memory_barrier (void) { __sync(); } +static inline void _hb_memory_barrier (void) { __lwsync(); } #define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N)) commit fd638d215feb058c2294e447cc68f6f50e2b481d Author: Behdad Esfahbod Date: Tue Jul 31 23:00:15 2018 -0700 [atomic] Add XXX items around Solaris ops Since add_int and cas are both read-modify-write, I wonder if we also need a barrier after them. diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index ef72872a..0d0badfb 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -122,11 +122,11 @@ static inline void _hb_memory_barrier (void) { __sync_synchronize (); } #include typedef unsigned int hb_atomic_int_impl_t; -#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv ((AI), (V)) - (V)) +#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv ((AI), (V)) - (V) /* XXX barrier again? */) static inline void _hb_memory_barrier (void) { __machine_rw_barrier (); } -#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false /* XXX barrier again? */) #elif !defined(HB_NO_MT) && defined(__APPLE__) ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz