Skip to content

use counter instead of pointer cast for obj id#9

Open
seeduvax wants to merge 1 commit intostetre:masterfrom
seeduvax:master
Open

use counter instead of pointer cast for obj id#9
seeduvax wants to merge 1 commit intostetre:masterfrom
seeduvax:master

Conversation

@seeduvax
Copy link

@seeduvax seeduvax commented Nov 6, 2023

On my x86_64 Debian 12 host, using lua5.4:

  • object Ids are not well passed back from lua to C.
  • created objects can't be found, making errors like "invalid ring buffer reference" It seems it is because lua numbers are double and the way big 64bits uintptr_t values are assigned ans cast to/from lua double does not preserve identity (in particular when pointers value are starting with 0xff, making negative value in lua side).

To solve this issue, key values are now generated with simple counters starting from specific remarkable values accoring type (128, 1024, 2048, etc). Since I do not expect so much keys shall be created from a single script, I do not expect the counters will increase so much improper values like the pointers can be reached.

To be considered: protect counter increments with mutex. Did not implemented yet since my understanding of luajack is new object shall be created from the main thread before jack.activate(), so such mutex appears to be useless.

On my x86_64 Debian 12 host, using lua5.4:
- object Ids are not well passed back from lua to C.
- created objects can't be found, making errors like
  "invalid ring buffer reference"
It seems it is because lua numbers are double and the way big
64bits uintptr_t values are assigned ans cast to/from lua double
does not preserve identity (in particular when pointers value are
starting with 0xff, making negative value in lua side).

To solve this issue, key values are now generated with simple counters
starting from specific remarkable values accoring type (128, 1024, 2048,
etc). Since I do not expect so much keys shall be created from a single
script, I do not expect the counters will increase so much improper
values like the pointers can be reached.

To be considered: protect counter increments with mutex. Did not
implemented yet since my understanding of luajack is new object shall be
created from the main thread before jack.activate(), so such mutex
appears to be useless.
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