diff --git a/beniget/beniget.py b/beniget/beniget.py
index 4faa64d..fe38b13 100644
--- a/beniget/beniget.py
+++ b/beniget/beniget.py
@@ -665,6 +665,14 @@ class DefUseChains(ast.NodeVisitor):
     def extend_global(self, name, dnode_or_dnodes):
         if self._deadcode:
             return
+        # `name` *should* be in self._definitions[0] because we extend the
+        # globals. Yet the original code maybe faulty and we need to cope with
+        # it.
+        if name not in self._definitions[0]:
+            if isinstance(dnode_or_dnodes, Def):
+                self.locals[self.module].append(dnode_or_dnodes)
+            else:
+                self.locals[self.module].extend(dnode_or_dnodes)
         DefUseChains.add_to_definition(self._definitions[0], name,
                                        dnode_or_dnodes)
 

diff --git a/tests/test_chains.py b/tests/test_chains.py
index 1e9bdaa..d2fa72c 100644
--- a/tests/test_chains.py
+++ b/tests/test_chains.py
@@ -111,6 +111,9 @@ class TestDefUseChains(TestCase):
         self.checkChains(code, ['a -> (a -> ())',
                                 'foo -> ()'])
 
+    def test_augassign_undefined_global(self):
+        code = "def foo():\n def bar():\n  global x\n  x+=1; x"
+        self.checkChains(code, ['foo -> ()', 'x -> (x -> ())'], strict=False)
 
     def test_expanded_augassign(self):
         code = "a = 1; a = a + 2"

AssertionError in the __debug__ sanity checks when parsing idlelib.config
It can be reproduced as follows, but I don't have a minimal reproducer at the moment.

```
% curl --silent https://raw.githubusercontent.com/python/cpython/3.12/Lib/idlelib/config.py > test.py
% python3 -m beniget test.py 
W: unbound identifier 'line' at test.py:885:8
W: unbound identifier 'crc' at test.py:886:50
[...]
  File "beniget/beniget.py", line 616, in visit_Module
    assert nb_defs == nb_heads + nb_bltns - nb_overloaded_bltns
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```

tests/test_chains.py::TestDefUseChains::test_augassign_undefined_global
tests/test_chains.py::TestDefUseChains::test_annotation_in_functions_locals tests/test_chains.py::TestDefUseChains::test_annotation_in_inner_functions_locals tests/test_chains.py::TestDefUseChains::test_annotation_inner_class tests/test_chains.py::TestDefUseChains::test_annotation_inner_inner_fn tests/test_chains.py::TestDefUseChains::test_annotation_unbound tests/test_chains.py::TestDefUseChains::test_annotation_unbound_pep563 tests/test_chains.py::TestDefUseChains::test_annotation_use_upper_scope_variables tests/test_chains.py::TestDefUseChains::test_annotation_uses_class_level_name tests/test_chains.py::TestDefUseChains::test_annotation_very_nested tests/test_chains.py::TestDefUseChains::test_arg_annotation tests/test_chains.py::TestDefUseChains::test_assign_in_loop tests/test_chains.py::TestDefUseChains::test_assign_in_loop_in_conditional tests/test_chains.py::TestDefUseChains::test_assign_in_while_in_conditional tests/test_chains.py::TestDefUseChains::test_assign_uses_class_level_name tests/test_chains.py::TestDefUseChains::test_assign_uses_class_level_same_name tests/test_chains.py::TestDefUseChains::test_attr tests/test_chains.py::TestDefUseChains::test_attribute_assignment tests/test_chains.py::TestDefUseChains::test_augassign tests/test_chains.py::TestDefUseChains::test_augassign_in_loop tests/test_chains.py::TestDefUseChains::test_base_class_uses_class_level_same_name tests/test_chains.py::TestDefUseChains::test_break_in_loop tests/test_chains.py::TestDefUseChains::test_call_assignment tests/test_chains.py::TestDefUseChains::test_class_base tests/test_chains.py::TestDefUseChains::test_class_decorator tests/test_chains.py::TestDefUseChains::test_class_scope_comprehension tests/test_chains.py::TestDefUseChains::test_class_scope_comprehension_invalid tests/test_chains.py::TestDefUseChains::test_complex_for_orelse tests/test_chains.py::TestDefUseChains::test_complex_while_orelse tests/test_chains.py::TestDefUseChains::test_continue_in_loop tests/test_chains.py::TestDefUseChains::test_def_used_in_self_default tests/test_chains.py::TestDefUseChains::test_expanded_augassign tests/test_chains.py::TestDefUseChains::test_expression_chain tests/test_chains.py::TestDefUseChains::test_for_break tests/test_chains.py::TestDefUseChains::test_for_pass tests/test_chains.py::TestDefUseChains::test_functiondef_returns tests/test_chains.py::TestDefUseChains::test_future_annotation_class_var tests/test_chains.py::TestDefUseChains::test_if_both_branch tests/test_chains.py::TestDefUseChains::test_if_false_branch tests/test_chains.py::TestDefUseChains::test_if_in_loop tests/test_chains.py::TestDefUseChains::test_if_true_branch tests/test_chains.py::TestDefUseChains::test_ifexp_chain tests/test_chains.py::TestDefUseChains::test_import_dotted_name_binds_first_name tests/test_chains.py::TestDefUseChains::test_import_from tests/test_chains.py::TestDefUseChains::test_import_from_as tests/test_chains.py::TestDefUseChains::test_lambda_defaults tests/test_chains.py::TestDefUseChains::test_lookup_scopes tests/test_chains.py::TestDefUseChains::test_maybe_unbound_identifier_message_format tests/test_chains.py::TestDefUseChains::test_method_annotation_unbound tests/test_chains.py::TestDefUseChains::test_method_annotation_unbound_pep563 tests/test_chains.py::TestDefUseChains::test_method_function_conflict tests/test_chains.py::TestDefUseChains::test_multiple_import_as tests/test_chains.py::TestDefUseChains::test_multiple_import_from_as tests/test_chains.py::TestDefUseChains::test_multiple_wildcards_may_bind tests/test_chains.py::TestDefUseChains::test_named_expr_complex tests/test_chains.py::TestDefUseChains::test_named_expr_comprehension tests/test_chains.py::TestDefUseChains::test_named_expr_comprehension_invalid tests/test_chains.py::TestDefUseChains::test_named_expr_simple tests/test_chains.py::TestDefUseChains::test_named_expr_with_rename tests/test_chains.py::TestDefUseChains::test_nested_if tests/test_chains.py::TestDefUseChains::test_nested_if_else tests/test_chains.py::TestDefUseChains::test_nested_while tests/test_chains.py::TestDefUseChains::test_no_unbound_local_identifier_in_comp tests/test_chains.py::TestDefUseChains::test_pep0563_annotations tests/test_chains.py::TestDefUseChains::test_pep563_self_referential_annotation tests/test_chains.py::TestDefUseChains::test_pep563_type_alias_override_class tests/test_chains.py::TestDefUseChains::test_read_global_from_branch tests/test_chains.py::TestDefUseChains::test_reassign_in_loop tests/test_chains.py::TestDefUseChains::test_redef_try_except tests/test_chains.py::TestDefUseChains::test_redefinition_in_comp tests/test_chains.py::TestDefUseChains::test_simple_except tests/test_chains.py::TestDefUseChains::test_simple_expression tests/test_chains.py::TestDefUseChains::test_simple_for tests/test_chains.py::TestDefUseChains::test_simple_for_orelse tests/test_chains.py::TestDefUseChains::test_simple_import tests/test_chains.py::TestDefUseChains::test_simple_import_as tests/test_chains.py::TestDefUseChains::test_simple_lambda tests/test_chains.py::TestDefUseChains::test_simple_print tests/test_chains.py::TestDefUseChains::test_simple_redefinition tests/test_chains.py::TestDefUseChains::test_simple_try tests/test_chains.py::TestDefUseChains::test_simple_try_except tests/test_chains.py::TestDefUseChains::test_simple_while tests/test_chains.py::TestDefUseChains::test_star_assignment tests/test_chains.py::TestDefUseChains::test_star_assignment_nested tests/test_chains.py::TestDefUseChains::test_star_import_with_conditional_redef tests/test_chains.py::TestDefUseChains::test_straight_raise tests/test_chains.py::TestDefUseChains::test_try_except tests/test_chains.py::TestDefUseChains::test_type_destructuring_for tests/test_chains.py::TestDefUseChains::test_type_destructuring_list tests/test_chains.py::TestDefUseChains::test_type_destructuring_starred tests/test_chains.py::TestDefUseChains::test_type_destructuring_tuple tests/test_chains.py::TestDefUseChains::test_unbound_class_variable tests/test_chains.py::TestDefUseChains::test_unbound_class_variable2 tests/test_chains.py::TestDefUseChains::test_unbound_class_variable3 tests/test_chains.py::TestDefUseChains::test_unbound_class_variable4 tests/test_chains.py::TestDefUseChains::test_unbound_class_variable5 tests/test_chains.py::TestDefUseChains::test_unbound_class_variable_reference_message_format tests/test_chains.py::TestDefUseChains::test_unbound_identifier_message_format tests/test_chains.py::TestDefUseChains::test_unbound_local_identifier_in_augassign tests/test_chains.py::TestDefUseChains::test_unbound_local_identifier_in_func tests/test_chains.py::TestDefUseChains::test_unbound_local_identifier_in_method tests/test_chains.py::TestDefUseChains::test_unbound_local_identifier_nonlocal tests/test_chains.py::TestDefUseChains::test_while_break tests/test_chains.py::TestDefUseChains::test_while_cond_break tests/test_chains.py::TestDefUseChains::test_while_cond_continue tests/test_chains.py::TestDefUseChains::test_while_nested_break tests/test_chains.py::TestDefUseChains::test_while_orelse_break tests/test_chains.py::TestDefUseChains::test_wilcard_import_annotation tests/test_chains.py::TestDefUseChains::test_wilcard_import_annotation_and_global_scope tests/test_chains.py::TestDefUseChains::test_wildcard_may_override tests/test_chains.py::TestDefUseChains::test_with_handler tests/test_chains.py::TestUseDefChains::test_call tests/test_chains.py::TestUseDefChains::test_simple_expression