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

Windows + [email protected]: SafeQL crashes with error code 127, error code 3221226505 #243

Open
ProchaLu opened this issue Jul 12, 2024 · 2 comments

Comments

@ProchaLu
Copy link

ProchaLu commented Jul 12, 2024

Describe the bug
SafeQL throws wrong errors with [email protected] on Windows and MacOS.

Issue also reported in VSCode ESlint repo:

Misleading errors:

  • incorrect table name (user instead of users)
  • missing comma (should be after users.id)
  • curly brackets instead of parentheses (after ON)
Screenshot 2024-07-12 at 16 35 46

On macOS ESlint throws these errors:

➜  safeql-eslint-broken git:(main) ✗ pnpm eslint . --max-warnings 0
(node:48991) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.
Pages directory cannot be found at /Users/lukas/Documents/UpLeveled/safeql-eslint-broken/pages or /Users/lukas/Documents/UpLeveled/safeql-eslint-broken/src/pages. If using a custom path, please configure with the `no-html-link-for-pages` rule in your eslint config file.

/Users/lukas/Documents/UpLeveled/safeql-eslint-broken/database.ts
  13:0  error  Invalid Query: Error: syntax error at or near "."  @ts-safeql/check-sql
  35:0  error  Invalid Query: Error: syntax error at or near "{"  @ts-safeql/check-sql

On Windows ESlint throws an error code 127 "command not found"

$ pnpm eslint . --max-warnings 0
(node:11440) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
$ echo $?
127

On Windows with these issues, the ESLint VSCode extension crashes after 5 times in 3 minutes

Screenshot 2024-07-09 141747

To Reproduce

  1. Clone repo git clone https://github.com/ProchaLu/safeql-eslint-broken
  2. set .env variables
  3. migrate up
  4. Check the code and errors in the database.ts file

Expected behavior
The expected behavior would be that SafeQL throws correct errors.

  • incorrect table name (user instead of users)
Screenshot 2024-07-12 at 16 44 39
  • missing comma (should be after users.id)
    The error should lead to the missing comma.
export async function getUsers1() {
  return await sql<Users[]>`
    SELECT
      users.id,
      users.name
    FROM
      users
  `;
}
  • curly brackets instead of parentheses (after ON)
    The error should lead to the wrong use of curly brackets.
export const getUsers3 = async (sessionToken: string) => {
  const users = await sql<{ id: number; name: string }[]>`
    SELECT
      users.*
    FROM
      users
      INNER JOIN sessions ON (
        sessions.token = ${sessionToken}
        AND expiry_timestamp > now()
      )
  `;
  return users;
};

OS: Windows
PostgreSQL version 15.7

@karlhorky karlhorky changed the title SafeQL reports unexpected errors and crashes with [email protected] Windows: SafeQL reports unexpected errors and crashes with [email protected] Sep 8, 2024
@karlhorky karlhorky changed the title Windows: SafeQL reports unexpected errors and crashes with [email protected] Windows + [email protected]: SafeQL crashes with error code 127, error code 3221226505 Sep 8, 2024
@karlhorky
Copy link
Collaborator

Using the research strategy from issue #261, I've decoded the error code 3221226505 to the hex code 0xC0000409, which is more googlable.

How do you diagnose the exception code 0xc0000409 on Windows? | Stack Overflow

0xc0000409 means STATUS_STACK_BUFFER_OVERRUN.

In other words, something in your program is writing past the current stack frame, corrupting data on the stack. The program has detected this and rather than let it continue, has thrown an exception.

@karlhorky
Copy link
Collaborator

I've also reported this in a new libpg-query issue, to surface the crashes over there too:

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

2 participants