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

fix: prisma --version (#13737) #14053

Merged
merged 16 commits into from
Jul 4, 2022
Merged

fix: prisma --version (#13737) #14053

merged 16 commits into from
Jul 4, 2022

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Jun 29, 2022

Essentially, PR #13737 without breaking ecosystem-tests.

Closes #14014.

@jkomyno
Copy link
Contributor Author

jkomyno commented Jun 29, 2022

Most likely, an invocation of these lines from inside pkg caused a segmentation fault:

export async function getEngineVersion(enginePath?: string, binaryName?: BinaryType): Promise<string> {
  if (!binaryName) {
    binaryName = getCliQueryEngineBinaryType()
  }
  // >>> from here:  
  enginePath = await resolveBinary(binaryName, enginePath)
  if (binaryName === BinaryType.libqueryEngine) {
    await isNodeAPISupported()

    const QE = load<NodeAPILibraryTypes.Library>(enginePath)
    return `libquery-engine ${QE.version().commit}`
  } else {
    // ...
  }
}

The previous code in #13737 assumed that the engine version could be read in a logical try / catch expression, resulting in either a string, or an error. Apparently, if enginePath is undefined, the execution of the above lines fails badly, causing the require defined inside load to read memory it's not supposed to read, thus causing a segmentation fault.

This problem was solved by making sure we read a proper binary path (preferring the one retrieved from environment variables) before even attempting to read any version.

@jkomyno jkomyno added this to the 4.1.0 milestone Jun 29, 2022
@jkomyno jkomyno marked this pull request as ready for review July 1, 2022 08:55
@jkomyno jkomyno requested a review from Jolg42 as a code owner July 1, 2022 08:55
@jkomyno jkomyno requested review from a team and aqrln and removed request for a team July 1, 2022 08:55
@jkomyno jkomyno merged commit 60b7b77 into main Jul 4, 2022
@jkomyno jkomyno deleted the integration/fix-version-pkg branch July 4, 2022 08:34
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

Successfully merging this pull request may close these issues.

prisma --version crashes if openssl isn't properly installed
2 participants