globals.c

Branch


Log

Author Commit Date CI Message
Nick Wellnhofer d87d9477 2025-09-29T10:46:47 Revert "globals: Don't export DllMain on Windows" This reverts commit bd2072f8d025e7a37d527b23b84698460c5798bf. Apparently, this change would require to recompile downstream code.
Nick Wellnhofer bd2072f8 2025-09-27T19:07:38 globals: Don't export DllMain on Windows This shouldn't be done and lld 21 warns about it: https://github.com/msys2/MINGW-packages/issues/17820 https://github.com/msys2/MINGW-packages/issues/25716 Regressed with f05af837.
Nick Wellnhofer 37bd4b28 2025-08-01T15:30:08 globals: Include HTMLparser.h, fixing Windows build Regressed with c011e760 and 85bd58ef. Fixes #961.
Nick Wellnhofer 220c813e 2025-06-03T23:33:02 globals: Fix documentation of xmlThrDef* functions
Nick Wellnhofer f6eec6f4 2025-06-02T22:45:19 globals: Remove lineNumbersDefaultValue from globals struct
Nick Wellnhofer 6a6a46f0 2025-05-28T16:02:41 doc: Fix autolink errors Fix links, remove links to internal functions.
Nick Wellnhofer 7bd8d1d9 2025-05-28T15:53:38 doc: Prefix autolinks with '#' Use `#func` instead of `func()` to ignore parameters and make all autolinks work.
Nick Wellnhofer b79cf474 2025-05-26T15:34:48 globals: Fix memory leak on Windows DLL unload Thread-local memory must be freed for the main thread as well after 4f08a1a2. Fixes #925.
Nick Wellnhofer 344190db 2025-05-16T00:54:51 doc: Document deprecated xmlThrDef* functions
Nick Wellnhofer 6f4b4527 2025-05-15T23:43:32 parser: Stop using ctxt->linenumbers I think this was used to avoid setting the `line` member before it was added (20+ years ago).
Nick Wellnhofer adfbeb7e 2025-05-14T04:58:21 doc: Stop using *Ptr typedefs in documentation
Nick Wellnhofer 2d83a84c 2025-05-14T00:29:19 doc: Misc improvements
Nick Wellnhofer 9bbffec5 2025-05-06T17:42:46 doc: Move brief to top, params to bottom of doc comments
Nick Wellnhofer cb1635a6 2025-05-02T19:05:25 doc: Use @since command
Nick Wellnhofer e78e05c9 2025-05-02T17:32:51 doc: Fix autolinks to functions Unfortunately, autolinks in .c files aren't converted by Doxygen for some reason.
Nick Wellnhofer f7c41287 2025-05-02T15:57:17 doc: Remove more comment block headers
Nick Wellnhofer e525564f 2025-05-01T19:20:06 doc: Remove empty lines at start of block These lines were left over after automatic conversion.
Nick Wellnhofer e549622b 2025-04-28T15:11:24 doc: Convert documentation to Doxygen Automated conversion based on a few regexes.
Nick Wellnhofer 69879da8 2025-04-28T14:04:30 doc: Remove email addresses from documentation Also remove authorship information from generated files, hash.c and globals.c which were rewritten.
Nick Wellnhofer 0aa87d85 2025-04-04T12:27:21 globals: Fix --with-thread-alloc build
Nick Wellnhofer 2af05f76 2025-03-05T11:10:20 globals: Fix Windows build
Nick Wellnhofer 69657224 2025-03-04T20:32:02 globals: Remove unused globals - xmlBufferAllocScheme - xmlDefaultBufferSize - xmlParserDebugEntities
Nick Wellnhofer 85bd58ef 2025-03-04T16:07:40 globals: Remove functions related to global state handling - xmlGetGlobalState - xmlInitializeGlobalState - xmlGetThreadId - xmlIsMainThread
Nick Wellnhofer 3d37ff84 2025-03-04T15:10:09 globals: Also use global state struct if threads are disabled
Nick Wellnhofer a15ad9b2 2025-03-04T14:06:50 parser: Remove compatibility symbols
Nick Wellnhofer 8e871162 2025-03-04T13:36:55 parser: Remove oldXMLWDcompatibility
Nick Wellnhofer cdc5cfed 2025-03-04T13:26:51 legacy: Remove legacy symbols
Nick Wellnhofer 2e3a91a7 2024-12-26T21:05:18 doc: Fix documentation
Nick Wellnhofer 2fcdc5f7 2024-11-18T20:41:09 globals: More comments on future directions
Nick Wellnhofer 1f7d4af3 2024-07-16T18:59:19 globals: Clean up macros and add comments
Nick Wellnhofer 4f08a1a2 2024-07-15T23:23:06 globals: Also use thread-specific storage on "main" thread Don't treat "main" thread specially. This simplifies access to thread-specific data. xmlGetGlobalState can now also fail on the former main thread, leading to an unrecoverable condition if malloc fails. The globals were never defined in public header files when compiling with thread support. Now they're only defined in a legacy build. Move TlsFree to DllMain to make cleanup more robust on Windows. Obsoletes #1.
Nick Wellnhofer a87944e9 2024-07-16T00:13:49 windows: Use DllMain for cleanup
Nick Wellnhofer 5f3f66c6 2024-07-15T23:50:08 threads: Use pthread_once and InitOnceExecuteOnce Static initialization flags aren't thread-safe. Also avoids an allocation on Windows. TODO: Breaks xmllint on Windows.
Nick Wellnhofer 79e11995 2024-07-15T19:43:28 error: Make xmlLastError const
Nick Wellnhofer 8e871a31 2024-07-07T12:58:43 buf: Rework xmlBuffer code Port most changes made to the xmlBuf code in f3807d76, except that "size" still includes the terminating NULL byte. Make xmlSetBufferAllocationScheme, xmlBufferAllocScheme and xmlDefaultBufferSize no-ops. Deprecate a few functions.
Nick Wellnhofer 72886980 2024-07-15T14:35:47 error: Add helper functions to print errors and abort
Nick Wellnhofer 6794c1b9 2024-07-02T19:51:05 globals: Document remaining thread-local vars as deprecated See #407.
Nick Wellnhofer 35146ff3 2024-07-02T19:43:24 save: Implement xmlSaveSetIndentString Allow to set indent string without using global xmlTreeIndentString. See #736.
Nick Wellnhofer 7cc619d5 2024-07-02T19:22:32 save: Implement save options for indenting Implement XML_SAVE_NO_INDENT to disable and XML_SAVE_INDENT to enable indenting regardless of the global xmlIndentTreeOutput. Implement XML_SAVE_EMPTY to enable empty tags regardless of the global xmlSaveNoEmptyTags. See #736.
Nick Wellnhofer f505dcae 2024-06-26T14:11:34 tree: Remove underscores from xmlRegisterCallbacks
Nick Wellnhofer 2b0c4abb 2024-06-16T21:52:12 threads: Remove pthread weak symbol hack On Linux, we tried to detect the presence of libpthread to disable things like locks. This questionable hack doesn't work since glibc 2.34 which merged libpthread into libc.
Nick Wellnhofer e75e878e 2024-05-20T13:58:22 doc: Update and fix documentation
Nick Wellnhofer 1cdfece1 2024-04-28T18:33:40 memory: Remove memory debugging This is useless compared to sanitizers or valgrind and has a considerable performance impact if enabled accidentally.
Nick Wellnhofer 12f0bb94 2024-01-05T01:14:28 parser: Synchronize more options
Nick Wellnhofer 9c2c87b5 2023-12-24T15:33:12 dict: Move local RNG state to global state Don't use TLS variables directly.
Nick Wellnhofer 54c70ed5 2023-12-18T19:31:29 parser: Improve error handling Introduce xmlCtxtSetErrorHandler allowing to set a structured error for a parser context. There already was the "serror" SAX handler but this always receives the parser context as argument. Start to use xmlRaiseMemoryError. Remove useless arguments from memory error functions. Rename xmlErrMemory to xmlCtxtErrMemory. Remove a few calls to xmlGenericError. Remove support for runtime entity debugging.
Nick Wellnhofer 9122ad0c 2023-12-06T19:56:50 include: Move globals from xmlsave.h to parser.h Fix downstream build issues after reworking globals.h.
Nick Wellnhofer c011e760 2023-12-06T01:09:31 globals: Remove unused globals from thread storage Setting these deprecated globals hasn't had an effect for a long time. Make them constants. This reduces the size of per-thread storage from ~700 to ~250 bytes.
Nick Wellnhofer 4c178040 2023-12-01T17:19:55 globals: Disable TLS in static Windows builds The cleanup callback would run after TLS was deallocated.
Mike Dalessio 62d318f8 2023-11-18T14:21:45 fix: more pthread weak references in globals.c
Mike Dalessio 1ac88300 2023-11-18T12:21:38 fix: pthread weak references in globals.c Linking executables will fail on systems with glibc < 2.34 without declaring these symbols as weak references. In commit c19771c1f13de9196f98260d142d8c8672eb5733 these references were moved to globals.c from threads.c, but the `#pragma weak` declarations were lost in the process. Also removing unneeded weak declarations from threads.c.
Nick Wellnhofer 253f260b 2023-10-18T20:06:35 threads: Fix --with-thread-alloc Fixes #606.
Nick Wellnhofer b8961a75 2023-09-27T17:22:17 parser: Fix reinitialization
Nick Wellnhofer bc4e82ff 2023-09-22T13:37:28 globals: Don't use thread-local storage on Darwin It seems that thread-local storage destructors are run before pthread thread-specific data destructors on Darwin, defeating our scheme to use TSD to clean up TLS. Here's an example program that reports a use-after-free when compiled with `-fsanitize=address` on macOS: #include <pthread.h> typedef struct { int v; } my_struct; static _Thread_local my_struct tls; pthread_key_t key; void dtor(void *tsd) { my_struct *s = (my_struct *) tsd; /* * This will crash ASan, apparently because * TLS has already been freed. */ s->v = 1; } void *thread(void *p) { pthread_setspecific(key, &tls); return NULL; } int main(void) { pthread_key_create(&key, dtor); pthread_t handle; pthread_create(&handle, NULL, thread, NULL); pthread_join(handle, NULL); return 0; }
Nick Wellnhofer 8c084ebd 2023-09-21T22:57:33 doc: Make apibuild.py happy
Nick Wellnhofer 05135536 2023-09-21T20:40:32 globals: Fix build --with-threads --without-output Fixes #593.
Nick Wellnhofer f0e8358e 2023-09-20T23:07:58 globals: Final fixes
Nick Wellnhofer 11a1839d 2023-09-20T17:54:48 globals: Move remaining globals back to correct header files This undoes a lot of damage.
Nick Wellnhofer eb985d6f 2023-09-20T17:17:49 globals: Move error globals back to xmlerror.c
Nick Wellnhofer d1336fd3 2023-09-20T17:00:50 globals: Move malloc hooks back to xmlmemory.h
Nick Wellnhofer a77f9ab8 2023-09-20T16:57:22 globals: Don't include SAX2.h from globals.h
Nick Wellnhofer 2e6c49a7 2023-09-20T14:43:14 globals: Don't store xmlParserVersion in global state This is a constant.
Nick Wellnhofer ea29b951 2023-09-20T13:30:01 globals: Abort if lazy allocation of global state failed There's really nothing we can do in this situation, so it's better to abort with an error message.
Nick Wellnhofer dc3382ef 2023-09-20T12:58:03 globals: Move xmlRegisterNodeDefault to tree.c Code in globals.c must not try to access globals itself since the accessor macros aren't defined and we would only see the main variable.
Nick Wellnhofer 75976742 2023-09-20T12:45:14 globals: Add a few comments
Nick Wellnhofer f7a403c2 2023-09-19T13:52:53 globals: Move xmlIsMainThread to globals.c xmlIsMainThread is mainly needed for global variables.
Nick Wellnhofer b173b724 2023-09-19T13:17:00 globals: Use thread-local storage if available Also use thread-local storage to store globals on POSIX platforms. Most importantly, this makes sure that global variable access can't fail when allocating the global state struct.
Nick Wellnhofer e7b6ca15 2023-09-18T13:25:06 globals: Rework global state destruction on Windows If DllMain is used, rely on it working as expected. The old code seemed to attempt to free global state of other threads if, for some reason, the DllMain mechanism didn't work. In a static build, register a destructor with RegisterWaitForSingleObject. Make public functions xmlGetGlobalState and xmlInitializeGlobalState no-ops. Move initialization and registration of global state objects to xmlInitGlobalState. Lookup global state with xmlGetThreadLocalStorage which can be inlined nicely. Also cleanup global state when using TLS. xmlLastError must be reset.
Nick Wellnhofer 39a275a5 2023-09-18T21:25:35 globals: Define globals using macros Declare and define globals and helper functions by (ab)using the preprocessor.
Nick Wellnhofer bf6bd161 2023-09-18T19:53:31 globals: Introduce xmlCheckThreadLocalStorage Checks whether (emulated) thread-local storage could be allocated.
Nick Wellnhofer 89f49767 2023-09-18T18:44:32 globals: Make xmlGlobalState private This removes a public struct but it seems impossible to use its members in a sensible way from external code.
Nick Wellnhofer 4e1c13eb 2023-09-18T14:45:10 debug: Remove debugging code This is barely useful these days and only clutters the code base.
Nick Wellnhofer c19771c1 2023-09-18T00:54:39 globals: Move code from threads.c to globals.c Move all code that handles globals to the place where it belongs.
Nick Wellnhofer 2a4b8114 2023-09-17T23:16:49 globals: Rename members of xmlGlobalState This is a deliberate first step to remove some internals from the public API and to avoid issues when redefining tokens.
Nick Wellnhofer 65d381f3 2022-11-24T20:54:18 threads: Allocate mutexes statically
Nick Wellnhofer 9dbf1374 2022-11-24T20:52:57 parser: Make some module init/cleanup functions private
Nick Wellnhofer cecd364d 2022-11-24T16:38:47 parser: Don't call *DefaultSAXHandlerInit from xmlInitParser Change the default handler definitions to match the result after calling the initialization functions. This makes sure that no thread-local variables are accessed when calling xmlInitParser.
Nick Wellnhofer ad338ca7 2022-09-01T01:18:30 Remove explicit integer casts Remove explicit integer casts as final operation - in assignments - when passing arguments - when returning values Remove casts - to the same type - from certain range-bound values The main motivation is that these explicit casts don't change the result of operations and only render UBSan's implicit-conversion checks useless. Removing these casts allows UBSan to detect cases where truncation or sign-changes occur unexpectedly. Document some explicit casts as truncating and add a few missing ones.
Nick Wellnhofer 0f568c0b 2022-08-26T01:22:33 Consolidate private header files Private functions were previously declared - in header files in the root directory - in public headers guarded with IN_LIBXML - in libxml.h - redundantly in source files that used them. Consolidate all private header files in include/private.
Nick Wellnhofer 3513d76a 2022-08-24T02:18:50 Improve documentation of globals Document more global variables as deprecated. Some of the variables don't generate deprecation warnings yet, but they shouldn't be used in new code.
Nick Wellnhofer 92bb889b 2022-08-24T00:03:44 Don't index anything in DOC_DISABLE sections Somewhat misleadingly, the DOC_DISABLE directive only disabled warnings. Now we really stop the documentation generator from indexing. This results in additional warnings for xmlThrDef* functions. This should be fixed by documenting or deprecating them.
Nick Wellnhofer 75b5bc2b 2022-08-23T20:57:49 Deprecate some global variables Most of these should be completely unused.
Nick Wellnhofer 4b184240 2022-08-22T14:11:15 Remove htmlDefaultSAXHandler from non-SAX1 build This matches long-standing behavior of the XML counterpart.
Nick Wellnhofer 40483d0c 2022-03-06T13:55:48 Deprecate module init and cleanup functions These functions shouldn't be part of the public API. Most init functions are only thread-safe when called from xmlInitParser. Global variables should only be cleaned up by calling xmlCleanupParser.
Nick Wellnhofer 4a8c71eb 2022-03-04T03:35:57 Remove DOCBparser This code has been broken and deprecated since version 2.6.0, released in 2003. Because of a bug in commit 961b535c, DOCBparser.c was never compiled since 2012. I couldn't find a Debian package using any of its symbols, so it seems safe to remove this module.
Nick Wellnhofer 5dcfbc49 2022-03-02T02:14:39 Move xmlCleanupGlobals to non-generated section The bottom of the file was generated by build_glob.py. The generator script needs some updates, but might still be useful.
Nick Wellnhofer 776d15d3 2022-03-02T00:29:17 Don't check for standard C89 headers Don't check for - ctype.h - errno.h - float.h - limits.h - math.h - signal.h - stdarg.h - stdlib.h - string.h - time.h Stop including non-standard headers - malloc.h - strings.h
Nick Wellnhofer 89d9ef3e 2022-03-01T15:14:00 Reset last error in xmlCleanupGlobals Before, we tried to reset the last error in xmlCleanupParser. But if xmlCleanupParser wasn't called from the main thread, this would reset the thread-local error object. xmlCleanupGlobals has access to the error object of the main thread and can reset it reliably.
Nick Wellnhofer 346c3a93 2022-02-20T18:46:42 Remove elfgcchack.h The same optimization can be enabled with -fno-semantic-interposition since GCC 5. clang has always used this option by default.
Nick Wellnhofer 20c60886 2020-03-08T17:19:42 Fix typos Resolves #133.
Jared Yanovich 2a350ee9 2019-09-30T17:04:54 Large batch of typo fixes Closes #109.
Nick Wellnhofer 71462a60 2017-11-09T13:42:33 Introduce xmlPosixStrdup and update xmlMemStrdup Introduce xmlPosixStrdup, an internal strdup implementation matching the POSIX strdup type signature, and update xmlMemStrdup to use it. Thanks to Vlad Tsyrklevich for the initial patch.
Daniel Veillard f8e3db04 2012-09-11T13:26:36 Big space and tab cleanup Remove all space before tabs and space and tabs at end of lines.
Akira TAGOH 961b535c 2012-07-03T14:13:59 Bug 676544 - fails to build with --without-sax1 Added some ifdef'd LIBXML_SAX1_ENABLED to make it buildable with --without-sax1 configure option.
Kai Henning 2c212838 2009-10-12T22:30:32 Fix an init bug in global.c * globals.c: fix the initialization of the mutex
MOD 44d1eff0 2009-09-09T19:03:13 594514 memory leaks - duplicate initialization * globals.c: xmlInitGlobals() might be called multiple times, leaking the xmlThrDefMutex value
Wang Lam 1de382eb 2009-08-24T17:34:25 Fix SetGenericErrorFunc and SetStructured clash * include/libxml/globals.h globals.c global.data: define a new global variable (per thread) for structured error reporting, to not conflict with generic one * error.c: when defined use the structured error report over any generic one
Daniel Veillard ccc476f1 2008-03-04T13:19:49 patch from Alex Khesin fixing CDATA output after a text node. fixed the * xmlwriter.c: patch from Alex Khesin fixing CDATA output after a text node. * parser.c: fixed the comment for xmlParserCleanup * globals.c: fixed indentation Daniel svn path=/trunk/; revision=3699
Rob Richards 91eb560c 2007-11-16T10:54:59 __xmlGlobalInitMutexDestroy() will free global_init_lock on Win32. Patch * globals.c threads.c include/libxml/threads.h: __xmlGlobalInitMutexDestroy() will free global_init_lock on Win32. Patch from Marc-Antoine Ruel. svn path=/trunk/; revision=3664
Daniel Veillard bca3ad25 2005-08-23T22:14:02 fixed compilation when configured --without-sax1 and other cleanups fixes * SAX2.c globals.c runtest.c testC14N.c testapi.c tree.c include/libxml/SAX2.h include/libxml/xmlregexp.h: fixed compilation when configured --without-sax1 and other cleanups fixes bug #172683 * doc/* elfgcchack.h: regenerated Daniel