BrianHumlicek / J2534-Sharp

A .Net interface for J2534 vehicle communications.
Other
43 stars 14 forks source link

Heap corruption 0xC0000374 #1

Closed syntroniks closed 5 years ago

syntroniks commented 5 years ago

Something is causing heap corruption. I tested this by adding extra calls to hJ2534MessageArray.ToMessageArray. Calling this function more often resulted in a heap corruption code sooner.

Triggering garbage collection makes this happen VERY fast.

Minimal example with GC:


var selectedInterface = interfaceList.First(a => a.Name == "Intrepid neoVI Fire/Red");
var api = SAE.J2534.APIFactory.GetAPI(selectedInterface.Filename);
var dev = api.GetDevice();
GC.Collect();
while (true) { Thread.Sleep(5); };

The program '[0x1B4] Example.exe' has exited with code -1073740940 (0xc0000374).
syntroniks commented 5 years ago

I modified GetDevice so it would only call PTOpen (not construct and return a new Device). The heap corruption still exists.

syntroniks commented 5 years ago

I ended up modifying some of the Heap* types to dispose differently. Seems to work -- PR incoming.

Alshain01 commented 5 years ago

I was having the same issue, incorporating the pull request into my project did correct it.

Tremo1984 commented 5 years ago

Attempting managed execution inside OS Loader lock.

APIFactory.GetAPI(FileName) Any help with the above tried disabling loader lock witch throws a debugging fault

syntroniks commented 5 years ago

@Tremo1984 That looks like a separate issue. Could you create a separate issue to track what you're seeing?

BrianHumlicek commented 5 years ago

Sorry about my delayed response. I have experienced this myself and found the issue. I will release a new version to correct it in a few days.

BrianHumlicek commented 5 years ago

I checked in a fix for this and rebuilt the package. Update your package in Nuget and verify this solves the issue.

syntroniks commented 5 years ago

👍 Solves the issue, things are working very well now. TY