WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.22k stars 390 forks source link

在loong64架构平台 一运行就报错 #1211

Closed haobaic closed 4 days ago

haobaic commented 1 week ago

Received signal 7 BUS_ADRERR 4600f800035f00

0 0x00aab3d9b8d8 base::debug::CollectStackTrace()

1 0x00aab3d8317c base::debug::StackTrace::StackTrace()

2 0x00aab3d9b790 base::debug::(anonymous namespace)::StackDumpSignalHandler()

3 0x00ffff8488a0 ([vdso]+0x89f)

4 0x00ff63ff9780

5 0x00aab0ddcf7c v8::internal::(anonymous namespace)::HandleApiCallHelper<>()

6 0x00aab0ddc80c v8::internal::Builtins::InvokeApiFunction()

7 0x00aab0ece9fc v8::internal::(anonymous namespace)::Invoke()

8 0x00aab0ecf828 v8::internal::Execution::New()

9 0x00aab0d7dbd4 v8::Function::NewInstanceWithSideEffectType()

10 0x00aab0d7d83c v8::Function::NewInstance()

11 0x00ff63fedf00

12 0x00aab1d0b2d0 Builtins_CallApiCallbackGeneric

[end of stack trace]

neoxpert commented 1 week ago

Can you provide more information about what you are trying to do? Which NodeJS / Electron version are you using. How does the code looks like, that can reproduce the exception?

Also, please note, the loong64 architecture is not covered with prebuilt binaries. That means you would have to setup a proper build tool chain for rebuilding better-sqlite3. While (cross-)compilation is working, there may still be adjustments required for running on loong64.

haobaic commented 1 week ago

使用的是 electron+better-sqlite3

version: electron:26.4.3 better-sqlite3 :9.6.0

注意是loong64架构平台

代码:

import { app, shell, BrowserWindow } from 'electron'
import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'

import Database from 'better-sqlite3'
import os from 'os'
function createWindow() {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 900,
    height: 670,
    show: false,
    autoHideMenuBar: true,
    ...(process.platform === 'linux' ? { icon } : {}),
    webPreferences: {
      preload: join(__dirname, '../preload/index.js'),
      sandbox: false
    }
  })

  mainWindow.on('ready-to-show', () => {
    mainWindow.show()
  })

  mainWindow.webContents.setWindowOpenHandler((details) => {
    shell.openExternal(details.url)
    return { action: 'deny' }
  })

  if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
    mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
  } else {
    mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
  }
}

app.whenReady().then(() => {
  // Set app user model id for windows
  electronApp.setAppUserModelId('com.electron')
  app.on('browser-window-created', (_, window) => {
    optimizer.watchWindowShortcuts(window)
  })
  async function exec() {
   try {
    let dbPath =join(os.homedir(), "/cdi_Client/cloudlnk.config");
    const db =new Database(dbPath, {
      verbose: (msg) => dbLogger.info(`[DB]: ${msg}`)
    })
    const result =await db.prepare("SELECT * FROM t_local_setting").all()

    console.log('res: ', result);
   } catch (error) {
     console.log('error: ', error);

   }
  }
  exec();
  createWindow()

  app.on('activate', function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow()
  })
})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})
mceachen commented 4 days ago

The loong64 is not supported by this library currently: the biggest hurdle is that docker run --platform would need to support something like linux/loong64.

I could mark this as an enhancement, I think I'll just close this, and when docker support is added, and a way to validate the build using emulation is provided, we can accept a PR to add this to the test and prebuild matrices.