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

Lua error inside app.transaction causes undefined behavior and crashes. #3276

Closed
nulldisk opened this issue May 4, 2022 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@nulldisk
Copy link

nulldisk commented May 4, 2022

If Lua throws an error inside app.transaction it is causing undefined behavior, eventually leading to segmentation fault.

It can be as simple as:

app.transaction(function()
    assert(crash)
end)

This causes a lot of random undefined behavior, mostly related to the undo history not working anymore or getting corrupted. Weird things can happen with selections too. If you continue in this state segmentation fault happens eventually.

It is possible to avoid it if you run your code inside a protected call like this:

app.transaction(function()
    local status, err = pcall(function()
        assert(crash)
    end)

    if status == false then
        print(err)
    end
end)

In this case the error is printed and nothing breaks.

I am on Linux, but I've briefly tried this on Windows as well and observed exact same behavior.

Aseprite and System version

  • Aseprite version: 1.3-beta-14-x64 (steam), 1.2.34.1-x64 (steam)
  • System: archlinux 5.17.3-arch1-1
@dacap dacap added bug critical priority scripting Related to scripting API labels May 4, 2022
@dacap dacap added this to the v1.2.35 milestone May 4, 2022
@dacap dacap modified the milestones: v1.2.35, v1.x-bugs Jun 1, 2022
@lampysprites
Copy link
Contributor

i think it's fixed in 4d18200 - same problem as #4431

@RefinedSoftwareLLC
Copy link

This is still happening with Aseprite v1.3.6-x64's AppImage.

This is my workaround:

local try = function(label, func)
  if not app.transaction(label,
    function()
      local ok, err = pcall(func)
      if ok then return true end
      app.alert{title=label, text=err}
    end)
  then
    app.undo()
  end
end

@dacap dacap modified the milestones: v1.x-bugs, v1.3.7 May 21, 2024
@dacap dacap self-assigned this May 21, 2024
@dacap
Copy link
Member

dacap commented May 21, 2024

Fixed in v1.3.7 released today with 4d18200

@dacap dacap closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants