poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pvm_execute_or_initialize SEGV with reproducer


From: Jose E. Marchesi
Subject: Re: pvm_execute_or_initialize SEGV with reproducer
Date: Thu, 22 Apr 2021 22:30:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Hi David.
>
> Thanks for reporting.
>
>> The same also occurs with none of the --disables, they serve to simplify
>> the backtrace.
>>
>> (poke) .file ~/playpen/btf/poke-fault/poke-fault.o
>> (poke) load elf
>> (poke) load "btf-dump.pk"  # note, this also loads btf.pk
>> (poke) var elf = Elf64_File @ 0#B
>> (poke) var shdr = elf.get_sections_by_name (".BTF") [0]
>> (poke) var btf = BTF_Section @ shdr.sh_offset
>
> I took a quick look, and it seems that the exceptions stack is being
> overflown.  This is probably a code generator bug: somehow we are not
> executing enough `pope' instructions for all the `pushe'.
>
> As far as I can see, we are starting to "leak" elements in the
> exceptions stack in:
>
>   (poke) var btf = BTF_Section @ shdr.sh_offset
>
> As soon as I have a little time I will look at all the places where the
> compiler is generating pushe/pope pairs and see what is going on..
> unless someone beats me to it :)


Ok this is now fixed by the commit below, which I have pushed to both
master and maint/poke-1.

It should fix your issue with btf-dump.


    pkl-gen: avoid leaking slots in the exceptions stack
    
    2021-04-22  Jose E. Marchesi  <jemarch@gnu.org>
    
            * libpoke/pkl-gen.pks (struct_mapper): Avoid "leaking" slots in
            the exceptions stack.
            (struct_field_mapper): Likewise.

diff --git a/ChangeLog b/ChangeLog
index f41839a7..0ece7ea0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-04-22  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * libpoke/pkl-gen.pks (struct_mapper): Avoid "leaking" slots in
+       the exceptions stack.
+       (struct_field_mapper): Likewise.
+
 2021-04-22  Mohammad-Reza Nabipoor  <m.nabipoor@yahoo.com>
 
        * libpoke/pvm-alloc.h (pvm_alloc_uncollectable): New function decl.
diff --git a/libpoke/pkl-gen.pks b/libpoke/pkl-gen.pks
index b344ea4a..b98a3673 100644
--- a/libpoke/pkl-gen.pks
+++ b/libpoke/pkl-gen.pks
@@ -155,6 +155,7 @@
         push null
         ba .arraymounted
 .constraint_error:
+        pope
         ;; Remove the partial element from the stack.
                                 ; ARR EOFF EOFF EXCEPTION
         drop
@@ -696,9 +697,9 @@
         fromr                   ; STRICT BOFF STRICT BOFF IOS
         swap                    ; STRICT BOFF STRICT IOS BOFF
         push PVM_E_CONSTRAINT
-        pushe .constraint_error_or_eof
+        pushe .constraint_error
         push PVM_E_EOF
-        pushe .constraint_error_or_eof
+        pushe .eof
         .c { int endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (@field);
         .c PKL_GEN_PAYLOAD->endian = PKL_AST_STRUCT_TYPE_FIELD_ENDIAN (@field);
         .c PKL_PASS_SUBPASS (PKL_AST_STRUCT_TYPE_FIELD_TYPE (@field));
@@ -708,9 +709,11 @@
         pope
         pope
         ba .val_ok
-.constraint_error_or_eof:
+.eof:
+        pope
+.constraint_error:
         ;; This is to keep the right lexical environment in
-        ;; case the subpass above raises a constraint exception.
+        ;; case the subpass above raises an exception.
         push null
         regvar $val
         raise
@@ -804,13 +807,14 @@
  .c     continue;
  .c   }
         .label .alternative_failed
+        .label .constraint_in_alternative
         .label .eof_in_alternative
  .c   if (PKL_AST_TYPE_S_UNION_P (@type_struct))
  .c   {
         push PVM_E_EOF
         pushe .eof_in_alternative
         push PVM_E_CONSTRAINT
-        pushe .alternative_failed
+        pushe .constraint_in_alternative
  .c   }
  .c   if (PKL_AST_TYPE_S_ITYPE (@type_struct))
  .c   {
@@ -918,6 +922,9 @@
      .c {
         raise
      .c }
+        ba .alternative_failed
+.constraint_in_alternative:
+        pope
 .alternative_failed:
         ;; Drop the exception and try next alternative.
         drop                    ; ...[EBOFF ENAME EVAL] NEBOFF



reply via email to

[Prev in Thread] Current Thread [Next in Thread]