Commit 5eb80e2d authored by Cosimo Cecchi's avatar Cosimo Cecchi

Merge branch 'fix-ci-bugs' into 'master'

Fix CI failures

See merge request GNOME/gjs!269
parents 2d59f7e4 0b443dc4
......@@ -629,9 +629,8 @@ flatpak:
variables:
TASK_ID: "flatpak packaging"
CODECHECK: "FLATPAK"
APPID: "org.gnome.GjsDevel"
BUNDLE: "org.gnome.GjsDevel.flatpak"
MANIFEST_PATH: "org.gnome.GjsDevel.json"
MANIFEST: org.gnome.GjsDevel.json
RUNTIME_REPO: "https://sdk.gnome.org/gnome-nightly.flatpakrepo"
environment:
......
......@@ -116,7 +116,7 @@ void BoxedInstance::allocate_directly(void) {
m_ptr = g_slice_alloc0(g_struct_info_get_size(info()));
m_allocated_directly = true;
debug_lifecycle("JSObject created by direct allocation");
debug_lifecycle("Boxed pointer directly allocated");
}
/* When initializing a boxed object from a hash of properties, we don't want
......@@ -255,6 +255,7 @@ static bool boxed_invoke_constructor(JSContext* context, JS::HandleObject obj,
*/
void BoxedInstance::copy_boxed(void* boxed_ptr) {
m_ptr = g_boxed_copy(gtype(), boxed_ptr);
debug_lifecycle("Boxed pointer created with g_boxed_copy()");
}
void BoxedInstance::copy_boxed(BoxedInstance* source) {
......@@ -300,8 +301,18 @@ bool BoxedInstance::constructor_impl(JSContext* context, JS::HandleObject obj,
/* Short-circuit construction for GVariants by calling into the JS packing
function */
const GjsAtoms& atoms = GjsContextPrivate::atoms(context);
return boxed_invoke_constructor(context, obj, atoms.new_internal(),
args);
if (!boxed_invoke_constructor(context, obj, atoms.new_internal(), args))
return false;
// The return value of GLib.Variant.new_internal() gets its own
// BoxedInstance, and the one we're setting up in this constructor is
// discarded.
m_not_owning_ptr = true;
debug_lifecycle(
"Boxed construction delegated to GVariant constructor, "
"boxed object discarded");
return true;
}
BoxedPrototype* proto = get_prototype();
......@@ -329,7 +340,7 @@ bool BoxedInstance::constructor_impl(JSContext* context, JS::HandleObject obj,
m_ptr = rval_arg.v_pointer;
debug_lifecycle("JSObject created with boxed instance");
debug_lifecycle("Boxed pointer created from zero-args constructor");
} else if (proto->can_allocate_directly()) {
allocate_directly();
......@@ -349,6 +360,14 @@ bool BoxedInstance::constructor_impl(JSContext* context, JS::HandleObject obj,
return false;
}
// The return value of the JS constructor gets its own BoxedInstance,
// and this one is discarded. Mark that the boxed pointer doesn't need
// to be freed, since it remains null.
m_not_owning_ptr = true;
debug_lifecycle(
"Boxed construction delegated to JS constructor, "
"boxed object discarded");
return true;
} else {
gjs_throw(context,
......@@ -459,6 +478,8 @@ bool BoxedInstance::get_nested_interface_object(
/* A structure nested inside a parent object; doesn't have an independent allocation */
priv->m_ptr = raw_ptr() + offset;
priv->m_not_owning_ptr = true;
priv->debug_lifecycle(
"Boxed pointer created, pointing inside memory owned by parent");
/* We never actually read the reserved slot, but we put the parent object
* into it to hold onto the parent object.
......@@ -991,6 +1012,7 @@ bool BoxedInstance::init_from_c_struct(JSContext* cx, void* gboxed, NoCopy) {
// a copy of it. Used for G_SIGNAL_TYPE_STATIC_SCOPE.
m_ptr = gboxed;
m_not_owning_ptr = true;
debug_lifecycle("Boxed pointer acquired, memory not owned");
return true;
}
......@@ -1000,6 +1022,7 @@ bool BoxedInstance::init_from_c_struct(JSContext* cx, void* gboxed) {
return true;
} else if (gtype() == G_TYPE_VARIANT) {
m_ptr = g_variant_ref_sink(static_cast<GVariant*>(gboxed));
debug_lifecycle("Boxed pointer created by sinking GVariant ref");
return true;
} else if (get_prototype()->can_allocate_directly()) {
copy_memory(gboxed);
......
......@@ -287,6 +287,7 @@ gjs_context_class_init(GjsContextClass *klass)
void GjsContextPrivate::trace(JSTracer* trc, void* data) {
auto* gjs = static_cast<GjsContextPrivate*>(data);
JS::TraceEdge<JSObject*>(trc, &gjs->m_global, "GJS global object");
gjs->m_atoms.trace(trc);
}
void GjsContextPrivate::warn_about_unhandled_promise_rejections(void) {
......
......@@ -503,8 +503,7 @@ static bool do_import(JSContext* context, JS::HandleObject obj, Importer* priv,
}
/* First try importing an internal module like gi */
if (priv->is_root &&
gjs_is_registered_native_module(context, obj, name.get())) {
if (priv->is_root && gjs_is_registered_native_module(name.get())) {
if (!gjs_import_native_module(context, obj, name.get()))
return false;
......
......@@ -23,31 +23,28 @@
#include <config.h>
#include <gmodule.h>
#include <string>
#include <unordered_map>
#include <util/log.h>
#include "gjs/jsapi-util.h"
#include "gjs/jsapi-wrapper.h"
#include "gjs/native.h"
#include "util/log.h"
#include "native.h"
#include "jsapi-wrapper.h"
#include "jsapi-util.h"
static GHashTable *modules = NULL;
static std::unordered_map<std::string, GjsDefineModuleFunc> modules;
void
gjs_register_native_module (const char *module_id,
GjsDefineModuleFunc func)
{
if (modules == NULL)
modules = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
if (g_hash_table_lookup(modules, module_id) != NULL) {
bool inserted;
std::tie(std::ignore, inserted) = modules.insert({module_id, func});
if (!inserted) {
g_warning("A second native module tried to register the same id '%s'",
module_id);
return;
}
g_hash_table_replace(modules, g_strdup(module_id), (void*) func);
gjs_debug(GJS_DEBUG_NATIVE,
"Registered native JS module '%s'",
module_id);
......@@ -55,23 +52,14 @@ gjs_register_native_module (const char *module_id,
/**
* gjs_is_registered_native_module:
* @context:
* @parent: the parent object defining the namespace
* @name: name of the module
*
* Checks if a native module corresponding to @name has already
* been registered. This is used to check to see if a name is a
* builtin module without starting to try and load it.
*/
bool
gjs_is_registered_native_module(JSContext *context,
JSObject *parent,
const char *name)
{
if (modules == NULL)
return false;
return g_hash_table_lookup(modules, name) != NULL;
bool gjs_is_registered_native_module(const char* name) {
return modules.count(name) > 0;
}
/**
......@@ -91,23 +79,18 @@ gjs_load_native_module(JSContext *context,
const char *parse_name,
JS::MutableHandleObject module_out)
{
GjsDefineModuleFunc func;
gjs_debug(GJS_DEBUG_NATIVE,
"Defining native module '%s'",
parse_name);
if (modules != NULL)
func = (GjsDefineModuleFunc) g_hash_table_lookup(modules, parse_name);
else
func = NULL;
const auto& iter = modules.find(parse_name);
if (!func) {
if (iter == modules.end()) {
gjs_throw(context,
"No native module '%s' has registered itself",
parse_name);
return false;
}
return func (context, module_out);
return iter->second(context, module_out);
}
......@@ -41,9 +41,7 @@ void gjs_register_native_module (const char *module_id,
/* called by importer.c to to check for already loaded modules */
GJS_USE
bool gjs_is_registered_native_module(JSContext *context,
JSObject *parent,
const char *name);
bool gjs_is_registered_native_module(const char* name);
/* called by importer.cpp to load a statically linked native module */
GJS_JSAPI_RETURN_CONVENTION
......
......@@ -158,6 +158,17 @@
fun:cairo_show_text
}
# https://gitlab.gnome.org/GNOME/gobject-introspection/issues/265
{
gobject-introspection-default-repository
Memcheck:Leak
match-leak-kinds: definite
fun:realloc
...
fun:build_typelib_key
fun:register_internal
}
# SpiderMonkey data races
# These are in SpiderMonkey's atomics / thread barrier stuff so presumably
......
......@@ -14,7 +14,7 @@ function do_Install_Dependencies(){
docbook docbook-xsl libtext-csv-perl \
zlib1g-dev libdbus-glib-1-dev \
libtool libicu-dev libnspr4-dev \
policykit-1 \
policykit-1 python3-setuptools \
libgtk-3-dev gir1.2-gtk-3.0 xvfb gnome-desktop-testing dbus-x11 dbus \
libedit-dev libgl1-mesa-dev lcov libreadline-dev
......
{
"id": "<<ID>>",
"branch": "<<master>>",
"id": "org.gnome.GjsDevel",
"branch": "master",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
......@@ -18,12 +18,11 @@
"modules": [
{
"name": "gjs",
"buildsystem": "autotools",
"builddir": true,
"sources": [
{
"type": "git",
"branch": "<<current>>",
"branch": "HEAD",
"path": "."
}
]
......
......@@ -297,15 +297,11 @@ elif [[ $1 == "FLATPAK" ]]; then
do_Print_Labels 'Flatpak packaging'
# Move the manifest file to the root folder
cp test/*.json .
cp "test/$MANIFEST" .
# Ajust to the current branch
sed -i "s,<<ID>>,$APPID,g" ${MANIFEST_PATH}
sed -i "s,<<master>>,master,g" ${MANIFEST_PATH}
sed -i "s,<<current>>,origin/$CI_COMMIT_REF_NAME,g" ${MANIFEST_PATH}
flatpak-builder --bundle-sources --repo=devel build ${MANIFEST_PATH}
flatpak build-bundle devel ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${APPID}
flatpak-builder --version
flatpak-builder --bundle-sources --repo=devel build "$MANIFEST"
flatpak build-bundle devel ${BUNDLE} --runtime-repo=${RUNTIME_REPO} org.gnome.GjsDevel
fi
# Releases stuff and finishes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment