Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random crashes occurring when calling into DLLs #194

Open
KasimAhmic opened this issue Sep 18, 2024 · 0 comments
Open

Random crashes occurring when calling into DLLs #194

KasimAhmic opened this issue Sep 18, 2024 · 0 comments

Comments

@KasimAhmic
Copy link

KasimAhmic commented Sep 18, 2024

I’ve been leveraging Koffi to create bindings for the AutoIt Windows automation library. I’ve been able to make great progress so far though there are lots of random crashes as I call the functions where the Node process just halts with no output and exists with code 0.

The majority of the crashes I’ve observed seem to be related to passing buffers to the underlying DLL. Passing a 1024 byte buffer is generally stable and I don’t often have issues with that but it still crashes from time to time. Passing a buffer larger than 1024 bytes (I usually use 2048 or 4096 bytes) seems to exacerbate the issue for a time and then it’ll start working fine, only for it to start crashing again.

Are there any debug flags I can enable in Koffi so that I can provide more details for this issue?

If you would like to reproduce the issue yourself, you can check out my project here and modify one of the more basic methods like WinGetText to pass a buffer of >1024 bytes.

  WinGetText(szTitle: TLPCWSTR, szText: TLPCWSTR = ''): string {
    const outputBuffer = Buffer.alloc(1024); // Change this to 2048 or greater

    this.invoke(
      'AU3_WinGetText',
      DataType.Void,
      [DataType.String16, DataType.String16, LPWSTR, DataType.Int32],
      [szTitle, szText, outputBuffer, outputBuffer.length],
    );

    return outputBuffer.toString('utf16le');
  }

Then you can use this basic script to attempt to trigger the crash:

const windowTitle = 'This PC'; // Change this to whatever Windows Explorer opens to by default for you

const autoit = new AutoIt();

autoit.load();
autoit.Run('explorer.exe');
autoit.WinWait(windowTitle);

const windowText = autoit.WinGetText(windowTitle, '');

console.log(windowText);

autoit.unload();

Any help is much appreciated and I’m happy to provide more details if needed!

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

No branches or pull requests

1 participant