Add mj_markStack and mj_freeStack as public API functions.
Also add asan instrumentation to detect stack frame leakages (i.e. `mj_markStack` without a corresponding `mj_freeStack` in the same caller function). PiperOrigin-RevId: 562625645 Change-Id: I4e3ff66ca0b9d08ed0a95cef45393db8e3053e22
This commit is contained in:
committed by
Copybara-Service
parent
9308e1d383
commit
94a8705ad0
@@ -677,6 +677,34 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
|
||||
),
|
||||
doc='Reset data, set fields from specified keyframe.',
|
||||
)),
|
||||
('mj_markStack',
|
||||
FunctionDecl(
|
||||
name='mj_markStack',
|
||||
return_type=ValueType(name='void'),
|
||||
parameters=(
|
||||
FunctionParameterDecl(
|
||||
name='d',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjData'),
|
||||
),
|
||||
),
|
||||
),
|
||||
doc='Mark a new frame on the mjData stack.',
|
||||
)),
|
||||
('mj_freeStack',
|
||||
FunctionDecl(
|
||||
name='mj_freeStack',
|
||||
return_type=ValueType(name='void'),
|
||||
parameters=(
|
||||
FunctionParameterDecl(
|
||||
name='d',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjData'),
|
||||
),
|
||||
),
|
||||
),
|
||||
doc='Free the current mjData stack frame. All pointers returned by mj_stackAlloc since the last call to mj_markStack must no longer be used afterwards.', # pylint: disable=line-too-long
|
||||
)),
|
||||
('mj_stackAlloc',
|
||||
FunctionDecl(
|
||||
name='mj_stackAlloc',
|
||||
|
||||
@@ -3502,6 +3502,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
||||
type=ValueType(name='size_t'),
|
||||
doc='first available mjtNum address in stack',
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='pbase',
|
||||
type=ValueType(name='size_t'),
|
||||
doc='value of pstack when mj_markStack was last called',
|
||||
),
|
||||
StructFieldDecl(
|
||||
name='parena',
|
||||
type=ValueType(name='size_t'),
|
||||
|
||||
Reference in New Issue
Block a user