-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
The following snippet will always fail with a segmentation fault or illegal hardware instruction:
local lgi = require("lgi")
local Gio = lgi.Gio
local src = Gio.File.new_for_path("/tmp/foo")
local dest = Gio.File.new_for_path("/tmp/bar")
local loop = lgi.GLib.MainLoop.new()
src:copy_async(dest, Gio.FileCopyFlags.NONE, 0, nil, nil, function(_, token)
local ok, err = src:copy_finish(token)
print(ok, err)
loop:quit()
end)
loop:run()The sync version Gio.File.copy works fine, as does the C equivalent to above:
#include <glib-2.0/glib.h>
#include <glib-2.0/gio/gio.h>
#include <stdio.h>
typedef struct
{
GError *error;
gboolean done;
gboolean res;
} Data;
static void
cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GFile *file = G_FILE (object);
Data *data = user_data;
GError *error = NULL;
data->res = g_file_copy_finish(file, result, &error);
data->error = error;
data->done = TRUE;
}
int main() {
GFile* src = g_file_new_for_path("/tmp/foo");
GFile* dest = g_file_new_for_path("/tmp/bar");
Data data = { 0 };
g_file_copy_async(src, dest, G_FILE_COPY_NONE, 0, NULL, NULL, NULL, cb, &data);
while (!data.done)
g_main_context_iteration (NULL, TRUE);
if (!data.res)
printf("%s\n", data.error->message);
}Versions:
$ lua -v
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
$ luarocks list lgi
Rocks installed for Lua 5.3
---------------------------
lgi
0.9.2-1 (installed) - $HOME/.luarocks/lib/luarocks/rocks-5.3
$ uname -a
Linux *** 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/LinuxReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels