misbehaving system halting work

Karl gmkarl at gmail.com
Fri Feb 26 11:22:39 PST 2021


On Fri, Feb 26, 2021, 12:14 PM coderman <coderman at protonmail.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> hello Karl!
>
> i haven't had time to dig into this much, but one thing stuck out to me
> in how you're using the FTDI content and functions.
>
> here you initialize the ftdi_content, but are using a local structure
> variable:
>
> https://github.com/xloem/brainflow/blob/ecd1049f3a4146bd24a0b21f50b5267eb1d6190d/src/utils/libftdi_serial.cpp#L40


At
https://github.com/xloem/brainflow/blob/ecd1049f3a4146bd24a0b21f50b5267eb1d6190d/src/utils/libftdi_serial.cpp#L34
I pass a pointer to the stack to a function that will deallocate from the
heap.  Maybe I fix that and reboot my system, it will be enough voodoo.


>
> once you return from  LibFTDISerial::is_libftdi () function, the
> ftdi_context will be destroyed.
>
> you'll notice that this context must live as long as the process, otherwise
> references to it will become invalid, leading to stack / heap corruption.
>
> for example, this usage calls from main(), where the ftdi_context will
> exist as long as the program is running:
>
> https://github.com/punyal/Contiki_3-IPsec/blob/93130cd1123f362594e915283dbf7f2783eeea43/platform/mulle/tools/scan_ftdi/scan_ftdi.c#L17
>
> you could solve this by declaring a static (global) ftdi_context, however,
>  this entails locking / concurrency concerns.
>
>
> i hope this helps. perhaps later this weekend i dig in depth into your
> problems.
>
>
> best regards,
>
> -----BEGIN PGP SIGNATURE-----
>
> iNUEAREKAH0WIQRBwSuMMH1+IZiqV4FlqEfnwrk4DAUCYDksRF8UgAAAAAAuAChp
> c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0NDFD
> MTJCOEMzMDdEN0UyMTk4QUE1NzgxNjVBODQ3RTdDMkI5MzgwQwAKCRBlqEfnwrk4
> DJSNAP4/21OaXu96TS2w7kZGQhurSOQilGQ+ZA4g6TllSIKUVgEAzbeQ7/hmf3Nw
> eZfqr5al/5d5LZF3bFcfKqJ1E1fmh8s=
> =EkrV
> -----END PGP SIGNATURE-----
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/html
Size: 2987 bytes
Desc: not available
URL: <https://lists.cpunks.org/pipermail/cypherpunks/attachments/20210226/b030ae81/attachment.txt>


More information about the cypherpunks mailing list