(code, signal)
| 535 | } |
| 536 | |
| 537 | function printCrashDiagnostics(code, signal) { |
| 538 | // Windows NTSTATUS codes (unsigned DWORD) |
| 539 | const unsignedCode = getUnsignedExitCode(code) |
| 540 | const isIllegalInstruction = |
| 541 | signal === 'SIGILL' || |
| 542 | (process.platform === 'win32' && unsignedCode === 0xC000001D) |
| 543 | const isAccessViolation = |
| 544 | signal === 'SIGSEGV' || |
| 545 | (process.platform === 'win32' && unsignedCode === 0xC0000005) |
| 546 | const isBusError = signal === 'SIGBUS' |
| 547 | const isAbort = |
| 548 | signal === 'SIGABRT' || |
| 549 | (process.platform === 'win32' && unsignedCode === 0xC0000409) |
| 550 | |
| 551 | if (!isIllegalInstruction && !isAccessViolation && !isBusError && !isAbort) return |
| 552 | |
| 553 | const exitInfo = signal ? `signal ${signal}` : `code ${code}` |
| 554 | console.error('') |
| 555 | console.error(`❌ ${packageName} exited immediately (${exitInfo})`) |
| 556 | console.error('') |
| 557 | |
| 558 | if (isIllegalInstruction) { |
| 559 | console.error('Your CPU may not support the required instruction set (AVX2).') |
| 560 | console.error('This typically affects CPUs from before 2013.') |
| 561 | console.error('Unfortunately, this binary is not compatible with your system.') |
| 562 | console.error('') |
| 563 | } else if (isAccessViolation) { |
| 564 | console.error('The binary crashed with an access violation.') |
| 565 | console.error('') |
| 566 | } else if (isBusError) { |
| 567 | console.error('The binary crashed with a bus error.') |
| 568 | console.error('This may indicate a platform compatibility issue.') |
| 569 | console.error('') |
| 570 | } else if (isAbort) { |
| 571 | console.error('The binary crashed with an abort signal.') |
| 572 | console.error('') |
| 573 | } |
| 574 | |
| 575 | console.error('System info:') |
| 576 | console.error(` Platform: ${process.platform} ${process.arch}`) |
| 577 | console.error(` Node: ${process.version}`) |
| 578 | console.error(` Binary: ${CONFIG.binaryPath}`) |
| 579 | console.error('') |
| 580 | console.error('Please report this issue at:') |
| 581 | console.error(' https://github.com/CodebuffAI/codebuff/issues') |
| 582 | console.error('') |
| 583 | } |
| 584 | |
| 585 | function getInstalledBinaryStatus() { |
| 586 | try { |
no test coverage detected