rusoku / CANAL-DLL

CANAL DLL for TouCAN USB to CAN bus converter
https://www.rusoku.com
MIT License
5 stars 2 forks source link

Some calls to CanalOpen cause heap corruption #2

Closed ad3154 closed 1 year ago

ad3154 commented 1 year ago

Hello there!

First off, big thanks for changing the license to MIT back in January!

We've recently integrated this DLL into our open source ISOBUS CAN stack at https://github.com/ad3154/Isobus-plus-plus/pull/220 and I noticed that it usually works, but sometimes when I call CanalOpen that something weird seems to be happening. More specifically, when CTouCANobj::Open is called, eventually it calls pDllList->RemoveAllNodes(&m_receiveList); which sometimes works, but other times it seems to cause heap corruption.

Screenshot 2023-03-21 103549

When this happens, if we inspect pdll it seems like nCount is suspiciously high, and the tail pointer of the CDllList seems suspicious also. The random nature of this happening makes it feel almost like a concurrency or initialization issue of some kind.

image

Anyways, I am not entirely sure what to make of it, but wanted to bring it to your attention. It is somewhat random but reproducible, so if you are interested in gathering some more information or troubleshooting I'd be happy to do what I can.

This was all tested using first the official released DLLs, but to actually debug in there and get the symbols needed, I compiled the DLL with Visual Studio 2022 17.5.3, specifically with compiler MSVC 19.35.32216.1 for 64 bit architecture to gather those screenshots.

Besides this, integrating this was very easy, so thank you again for your effort on that!

Regards, Adrian

rusoku commented 1 year ago

Thanks for the finding.I have never seen this before.I will check.

rusoku commented 1 year ago

I hope that this bug is fixed in the v1.0.5 release