Skip to content

Documented what bounds the size txm_module_object_allocate accepts - #50

Open
fdesbiens wants to merge 1 commit into
eclipse-threadx:mainfrom
fdesbiens:docs/module-object-allocation-overflow
Open

Documented what bounds the size txm_module_object_allocate accepts#50
fdesbiens wants to merge 1 commit into
eclipse-threadx:mainfrom
fdesbiens:docs/module-object-allocation-overflow

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

txm_module_object_allocate documented three of the five status codes it can return.

Two were already produced and undocumented:

  • TXM_MODULE_INVALID_MEMORY (0xF4), returned when object_ptr is NULL and there is nowhere to put the allocation.
  • TX_SIZE_ERROR (0x05), returned when the request is larger than the whole object pool. _txe_byte_allocate bounds every request by tx_byte_pool_size, so this is the code a caller sees for a size the pool cannot serve at all, as distinct from TX_NO_MEMORY for a pool that is merely too full right now.

One is new: TXM_MODULE_MATH_OVERFLOW (0xF8), for an object_size so large that adding the Module Manager's own object header to it would not be representable.

That distinction is only readable if the header is mentioned at all, so the description now says the manager keeps a header in front of the memory the module receives -- recording the owning module, the size, and the links that let the allocation be reclaimed when the module is unloaded -- and that object_size is therefore bounded by what the pool holds, less that header.

TXM_MODULE_MATH_OVERFLOW also joins the chapter's list of module-specific error codes at the top, which carried TXM_MODULE_INVALID_PROPERTIES, TXM_MODULE_INVALID_MEMORY and TXM_MODULE_INVALID_CALLBACK but not this one.

Verified by building the site with Antora; the three new mentions render as expected in threadx-modules/chapter4.html.

Matches a ThreadX change on fix/module-object-allocation-overflow.

The service's return values listed three of the five it can produce. Missing were
TXM_MODULE_INVALID_MEMORY, which a null object_ptr has always produced, and
TX_SIZE_ERROR, which the object pool produces for a size larger than the whole
pool -- the code a caller now sees where a size too large to add the manager's
header to at all produces TXM_MODULE_MATH_OVERFLOW instead.

That distinction is only readable if the header is mentioned, so the description
now says the manager keeps one in front of the memory the module receives and
that object_size is bounded by the pool less that header. TXM_MODULE_MATH_OVERFLOW
also joins the chapter's list of module-specific error codes, which had every
other code in its range and not that one.

Matches the ThreadX change on fix/module-object-allocation-overflow.

Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant