Commit Graph

60 Commits

Author SHA1 Message Date
Behdad Esfahbod 326b5ebf57 Poison freed objects such that double-free is detected
Previously we were setting refcount of freed objects to the inert value, which
was harmful because it caused further destroy()s of the freed object to NOT
call free() and hence hide the bug.  Indeed, after eb0bf3ae66 test-object
was double-free'ing objects and this was never caught on Linux.  It only was
caught as crashing on Mac.

Now we poison refcount upon freeing and check that it's valid whenever reading
it.  Makes test-object fail now.
2015-08-30 17:29:21 +01:00
Konstantin Ritt 3f174cd020 Minor refactoring to the atomics implementation
s/atomic_int/atomic_int_impl/ and s/atomic_ptr/atomic_ptr_impl/
to bring it in par with hb_mutex_impl_t, then re-introduce
hb_atomic_int_t as a wrapper around hb_atomic_int_impl_t.

In hb_reference_count_t, make it clear the non-atomic get and set
are intentional due to nature of the cases they are used in
(comparison to -1 and the debug output/tracing).
2015-04-08 13:04:22 -07:00
Behdad Esfahbod 0d2c2f238b Simplify hb-object 2014-08-14 13:25:55 -04:00
Behdad Esfahbod 9d861b81f3 Really fix clang build this time 2014-08-14 13:15:21 -04:00
Behdad Esfahbod 272226f294 Revert "Fix build on clang after previous commit"
This reverts commit 9c80cbc87f.
2014-08-14 13:11:33 -04:00
Behdad Esfahbod 9c80cbc87f Fix build on clang after previous commit 2014-08-14 13:09:52 -04:00
Behdad Esfahbod a5a27073cf Rewrite this==NULL checks to avoid undefined behavior
Fixes https://code.google.com/p/chromium/issues/detail?id=403594
2014-08-14 13:05:36 -04:00
Behdad Esfahbod cd7ea4f791 Make hb_object_t members private
In preparation for fixing:
https://code.google.com/p/chromium/issues/detail?id=403594
2014-08-14 12:57:02 -04:00
Behdad Esfahbod 7babfe5a79 Move object mutext into the user-data array
We are not using it for anything lse it seems.
2012-12-04 00:35:54 +02:00
Behdad Esfahbod a190011477 Remove unused functions 2012-12-04 00:29:35 +02:00
Behdad Esfahbod 2cf301968c Add hb_object_lock/unlock() 2012-06-09 14:58:01 -04:00
Behdad Esfahbod bd300df9ad Minor 2012-06-08 20:36:37 -04:00
Behdad Esfahbod 6220e5fc0d Add ASSERT_POD for most objects 2012-06-06 03:30:09 -04:00
Behdad Esfahbod cdafe3a7d8 Add gcc intrinsics implementations for atomic and mutex 2012-06-05 16:40:23 -04:00
Behdad Esfahbod 0e253e97af Add a mutex to object header
Removes one more static-initialization.  A few more to go.
2012-06-05 15:54:43 -04:00
Behdad Esfahbod bf93b636c4 Remove constructor from hb_prealloced_array_t
This was causing all object types to be non-POD and have static
initializers.  We don't need that!

Now, most nil objects just moved from .bss to .data.  Fixing for that
coming soon.
2012-06-05 14:17:32 -04:00
Behdad Esfahbod 3b8fd9c48f Remove const from ref_count.ref_count
According to Tom Hacohen this was breaking build with some compilers.

In file included from hb-buffer-private.hh:35:0,
                 from hb-ot-map-private.hh:32,
                 from hb-ot-shape-private.hh:32,
                 from hb-ot-shape.cc:29:
hb-object-private.hh: In constructor '_hb_object_header_t::_hb_object_header_t()':
hb-object-private.hh:97:8: error: uninitialized const member in 'struct hb_reference_count_t'
hb-object-private.hh:51:25: note: 'hb_reference_count_t::ref_count' should be initialized
In file included from hb-ot-shape.cc:33:0:
hb-set-private.hh: In constructor '_hb_set_t::_hb_set_t()':
hb-set-private.hh:37:8: note: synthesized method '_hb_object_header_t::_hb_object_header_t()' first required here
hb-ot-shape.cc: In function 'void hb_ot_shape_glyphs_closure(hb_font_t*, hb_buffer_t*, const hb_feature_t*, unsigned int, hb_set_t*)':
hb-ot-shape.cc:521:12: note: synthesized method '_hb_set_t::_hb_set_t()' first required here
2012-06-03 15:54:19 -04:00
Behdad Esfahbod 70600dbf62 Minor 2012-06-03 15:52:51 -04:00
Behdad Esfahbod 0558d55bac Remove hb_atomic_int_set/get()
We never use them in fact...

I'm just adjusting these as I better understand the requirements of
the code and the guarantees of each operation.
2012-05-28 10:46:47 -04:00
Behdad Esfahbod ec3ba4b96f Move atomic ops into their own header 2012-05-17 20:30:46 -04:00
Behdad Esfahbod 7bd2b04fea Minor 2012-05-11 03:40:58 +02:00
Behdad Esfahbod cf26510dbb Some more...
Done.  I promise.
2012-05-11 03:35:08 +02:00
Behdad Esfahbod bc71ad4973 Fix atomic-int op on Apple
The OSAtomicAdd32Barrier operator returns the new value, we want the
old value.
2012-03-01 17:30:29 -08:00
Behdad Esfahbod a1970d9afc Add support for atomic int and mutex on Apple systems
So, apparently there's no atomic int 'get' method on Apple.  You have to
add(0) to get.  And that's not const-friendly.  So switch inert-object
checking to a non-atomic get.  This, however, is safe, and a negligible
performance boost too.
2012-02-24 16:19:52 -05:00
Behdad Esfahbod 8004429102 Remove unused hb_atomic_int_set()
Apparently it can't be implemented on OS X.  We weren't using it anyway.
2012-02-24 16:19:52 -05:00
Behdad Esfahbod bd7ff1dec5 Allow disabling multi-threaded support
By defining HB_NO_MT.

Also, only warn once per missing MT feature support.

Mozilla Bug 666661 - gfx/harfbuzz/src/hb-prive.h - compiler warnings on mac
2012-02-23 15:06:16 -05:00
Behdad Esfahbod af92135424 Minor 2011-10-21 09:18:43 -07:00
Behdad Esfahbod 89d89646e8 Fix intrin.h b0rkage with older MSVC
Reported by Jonathan Kew.
2011-10-17 11:50:54 -07:00
Behdad Esfahbod d5476a30a1 Minor 2011-09-16 12:30:50 -04:00
Behdad Esfahbod 33ccc77902 [API] Make set_user_data() functions take a replace parameter
We need this to set data on objects safely without worrying that some
other thread unsets it by setting it at the same time.
2011-08-09 00:43:24 +02:00
Behdad Esfahbod c605bbbb6d Remove C++ guards from source files
Where causing issues for people with MSVC.
2011-08-04 20:00:53 -04:00
Behdad Esfahbod cc06c243d8 Streamline debugging infrastructure even more 2011-07-25 20:34:17 -04:00
Behdad Esfahbod 43ff203d8e Use variadic macros for debugging
Looks *so* much nicer!
2011-07-25 17:35:24 -04:00
Behdad Esfahbod decd4e3e16 Add sugar syntax for debug messages
Buffer debugging coming soon.
2011-07-25 16:47:02 -04:00
Behdad Esfahbod 31f18abecb Minor compiler warning fixes 2011-06-15 09:49:58 -04:00
Behdad Esfahbod b9452bfc16 Fix compiler warnings with -pedantic 2011-06-14 14:47:07 -04:00
Behdad Esfahbod df077fadd7 [object] Make object inert during destruction
Such that user_data and other finalizers cannot resurrect object
2011-05-12 01:19:39 -04:00
Behdad Esfahbod 45bfa99034 Fix set implementation to be truly threadsafe even with destroy() callbacks
The test/object test is passing again, instead of deadlocking.
2011-05-10 19:15:49 -04:00
Behdad Esfahbod 46df682851 Make user_data access threadsafe
For now, by taking a global user_data mutex.
2011-05-05 15:33:19 -04:00
Behdad Esfahbod 218e67b9ee Shrink code 2011-05-05 15:28:37 -04:00
Behdad Esfahbod b45f32ee4e Use hb_array_t for hb_language_t mapping 2011-05-05 15:00:43 -04:00
Behdad Esfahbod 21d2c92fdf Move code around 2011-05-05 14:47:53 -04:00
Behdad Esfahbod 811482bd65 Replace hb_map_t with hb_set_t which is more intuitive and flexible 2011-05-05 13:21:04 -04:00
Behdad Esfahbod 478a42536f Make array/map implementation more generic 2011-05-05 12:39:51 -04:00
Behdad Esfahbod 56eb5ad6f9 Move code around
Mutex (and Windows.h by extension) are fairly isolated now.
2011-05-04 19:27:37 -04:00
Behdad Esfahbod 2000179487 Move Win32 thread-safety stuff to hb-object-private.h
The Win32 definitions for LONG, ULONG, etc conflicts with
hb-open-type.h.  Avoid that by making sure hb-object-private.h
and hb-open-type.h are not included in the same compilation unit.
2011-05-03 00:49:06 -04:00
Behdad Esfahbod 1cd5969f25 [object] Fix bug in get_user_data() implementation 2011-05-02 19:53:39 -04:00
Behdad Esfahbod 852e08ec8f Move code around 2011-04-27 21:45:51 -04:00
Behdad Esfahbod 29c67d3f70 Add initial implementation of user_data to objects 2011-04-27 21:27:40 -04:00
Behdad Esfahbod 47e71d9661 [object] Remove unnecessary use of macros 2011-04-27 16:41:08 -04:00