alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
508 stars 45 forks source link

Lisp error: (args-out-of-range #<buffer *temp*> -1 5) when entering room on TTY emacs #81

Closed tsdh closed 2 years ago

tsdh commented 2 years ago

This is a followup to #80. The fix of that issue works but then I run into the next issue when trying to enter a room:

Debugger entered--Lisp error: (args-out-of-range #<buffer  *temp*> -1 5)                                                                                                       
  ement-room--format-message(#s(ement-event :id "$Cz6jM8KTion16..." :sender ... :content ... :origin-server-ts 1657548243279 :type "m.room.message" :unsigned ... :state-key n$
  ement-room--format-event(#s(ement-event :id "$Cz6jM8KTion16..." :sender ... :content ... :origin-server-ts 1657548243279 :type "m.room.message" :unsigned ... :state-key nil$
  ement-room--pp-thing(#s(ement-event :id "$Cz6jM8KTion16YDZahxnVNl6GWt7XpCxH8aJ3Yy-3Ls" :sender #s(ement-user :id "@alphapapa:matrix.org" :displayname nil :account-data nil $
  #f(compiled-function (data) #<bytecode 0x1060b2a6c0ab4a51>)(#s(ement-event :id "$Cz6jM8KTion16YDZahxnVNl6GWt7XpCxH8aJ3Yy-3Ls" :sender #s(ement-user :id "@alphapapa:matrix.o$
  ewoc--refresh-node(#f(compiled-function (data) #<bytecode 0x1060b2a6c0ab4a51>) [[[[[... #5 ... #<marker at 56 in *Ement Room: Ement.el*>] #4 #s(ement-room-membership-events$
  ewoc--insert-new-node([[[[[... #4 ... #<marker at 96 in *Ement Room: Ement.el*>] #3 #s(ement-event :id "$AJsxDz6oELMtemUFNtyfm9AM4MmJ2bQfrOiJ4..." :sender ... :content ... $
  ewoc-enter-before(#s(ewoc :buffer #<buffer *Ement Room: Ement.el*> :pretty-printer #f(compiled-function (data) #<bytecode 0x1060b2a6c0ab4a51>) :header [[[... #3 "" #<marker$
  ewoc-enter-after(#s(ewoc :buffer #<buffer *Ement Room: Ement.el*> :pretty-printer #f(compiled-function (data) #<bytecode 0x1060b2a6c0ab4a51>) :header [[[... #3 "" #<marker $
  ement-room--insert-event(#s(ement-event :id "$Cz6jM8KTion16YDZahxnVNl6GWt7XpCxH8aJ3Yy-3Ls" :sender #s(ement-user :id "@alphapapa:matrix.org" :displayname nil :account-data $
  #f(compiled-function (event) "`ement-room' handler function for m.room.message events." #<bytecode 0x19089b6c0048cdd3>)(#s(ement-event :id "$Cz6jM8KTion16YDZahxnVNl6GWt7XpC$
  ement-room--process-events((#s(ement-event :id "$mg_MXuQYDBhD6ScQPCzLInjQoukGDA2..." :sender #s(ement-user :id "@tsdh:matrix.org" :displayname nil :account-data nil :color $
  ement-room--buffer(#s(ement-session :user ... :server ... :token "syt_dHNkaA_zwj..." :transaction-id 4018620989 :rooms ... :next-batch "s3095641312_75..." :device-id nil :i$
  ement-view-room(#s(ement-room :id "!NicAJNwJawmHr..." :display-name "Ement.el" :prev-batch "t10023-3094820..." :summary ... :state ... :timeline ... :ephemeral ... :account$
  ement-room-list-action(#<marker (moves after insertion) at 537 in *Ement Rooms*>)                                                                                            
  button-activate(#<marker (moves after insertion) at 537 in *Ement Rooms*> nil)                                                                                               
  push-button(537)                                                                                                                                                             
  funcall-interactively(push-button 537)                                                                                                                                       
  call-interactively(push-button nil nil)                                                                                                                                      
  command-execute(push-button)                                                                                                                                                 

Now tried entering another room and got "Args out of range: #, 19, 45" where the *temp* buffer contents were %S%L%B%r%R%t which is also ement-room-message-format-spec. Is clear that those indices are bogus.

I can reproduce the issue also with this emacs -Q recipe:

emacs -Q -L .emacs.d/quelpa/build/ement -L .emacs.d/elpa/plz-0.1 -L .emacs.d/elpa/taxy-0.9 -L .emacs.d/elpa/taxy-magit-section-0.9.1 -L .emacs.d/elpa/magit-section-20220615.1159 -L .emacs.d/elpa/compat-28.1.1.
3 -L .emacs.d/elpa/dash-20220608.1931 -L .emacs.d/elpa/svg-lib-0.2.5 --eval "(progn (require 'ement) (require 'ement-room-list) (require 'ement-taxy))"

This happens only with the emacs instance on my server (current git master) which is configured like this:

./configure --with-modules --with-x-toolkit=no
...
Configured for 'x86_64-pc-linux-gnu'.                                                                                                                                                                              

  Where should the build process find the source code?    .                                                                                                                                                        
  What compiler should emacs be built with?               gcc -g3 -O2                                                                                                                                              
  Should Emacs use the GNU version of malloc?             no                                                                                                                                                       
    (The GNU allocators don't work with this system configuration.)                                                                                                                                                
  Should Emacs use a relocating allocator for buffers?    no                                                                                                                                                       
  Should Emacs use mmap(2) for buffer allocation?         no                                                                                                                                                       
  What window system should Emacs use?                    x11                                                                                                                                                      
  What toolkit should Emacs use?                          none                                                                                                                                                     
  Where do we find X Windows header files?                Standard dirs                                                                                                                                            
  Where do we find X Windows libraries?                   Standard dirs                                                                                                                                            
  Does Emacs use -lXaw3d?                                 no                                                                                                                                                       
  Does Emacs use -lXpm?                                   yes                                                                                                                                                      
  Does Emacs use -ljpeg?                                  yes                                                                                                                                                      
  Does Emacs use -ltiff?                                  yes                                                                                                                                                      
  Does Emacs use a gif library?                           yes -lgif                                                                                                                                                
  Does Emacs use a png library?                           yes -lpng16 -lz                                                                                                                                          
  Does Emacs use -lrsvg-2?                                no                                                                                                                                                       
  Does Emacs use -lwebp?                                  no                                                                                                                                                       
  Does Emacs use -lsqlite3?                               yes                                                                                                                                                      
  Does Emacs use cairo?                                   no                                                                                                                                                       
  Does Emacs use -llcms2?                                 yes                                                                                                                                                      
  Does Emacs use imagemagick?                             no                                                                                                                                                       
  Does Emacs use native APIs for images?                  no                                                                                                                                                       
  Does Emacs support sound?                               yes                                                                                                                                                      
  Does Emacs use -lgpm?                                   yes                                                                                                                                                      
  Does Emacs use -ldbus?                                  yes                                                                                                                                                      
  Does Emacs use -lgconf?                                 no                                                                                                                                                       
  Does Emacs use GSettings?                               yes                                                                                                                                                      
  Does Emacs use a file notification library?             yes -lglibc (inotify)                                                                                                                                    
  Does Emacs use access control lists?                    yes -lacl                                                                                                                                                
  Does Emacs use -lselinux?                               no                                                                                                                                                       
  Does Emacs use -lgnutls?                                yes                                                                                                                                                      
  Does Emacs use -lxml2?                                  yes                                                                                                                                                      
  Does Emacs use -lfreetype?                              no                                                                                                                                                       
  Does Emacs use HarfBuzz?                                no                                                                                                                                                       
  Does Emacs use -lm17n-flt?                              no                                                                                                                                                       
  Does Emacs use -lotf?                                   no                                                                                                                                                       
  Does Emacs use -lxft?                                   no                                                                                                                                                       
  Does Emacs use -lsystemd?                               yes                                                                                                                                                      
  Does Emacs use -ljansson?                               yes                                                                                                                                                      
  Does Emacs use the GMP library?                         yes                                                                                                                                                      
  Does Emacs directly use zlib?                           yes                                                                                                                                                      
  Does Emacs have dynamic modules support?                yes                                                                                                                                                      
  Does Emacs use toolkit scroll bars?                     no                                                                                                                                                       
  Does Emacs support Xwidgets?                            no                                                                                                                                                       
  Does Emacs have threading support in lisp?              yes                                                                                                                                                      
  Does Emacs support the portable dumper?                 yes                                                                                                                                                      
  Does Emacs support legacy unexec dumping?               no                                                                                                                                                       
  Which dumping strategy does Emacs use?                  pdumper                                                                                                                                                  
  Does Emacs have native lisp compiler?                   no                                                                                                                                                       
  Does Emacs use version 2 of the X Input Extension?      no                                                                                                                                                       
  Does Emacs generate a smaller-size Japanese dictionary? no                                                                                                                                                       

With the emacs built locally (also master but with toolkit/pgtk & native compliation) I can't reproduce the error, no matter if TTY frame or not.

tsdh commented 2 years ago

I think I have fixed it with this patch: https://paste.sr.ht/~tsdh/5399f5b8cf800a7e1b077a97f750c88f727a0ba4 I guess some formatter function does regex matching internally thereby clobbering our "outer" match data.

tsdh commented 2 years ago

Works!