DavRack / skr

Low level key re-programming
GNU General Public License v3.0
69 stars 3 forks source link

Crash on fedora32 #1

Closed gnufied closed 4 years ago

gnufied commented 4 years ago

It appears to be crashing on fedora:

(gdb) run                                                                                                                                     
Starting program: /usr/bin/skr                                                                                                                
[Detaching after vfork from child process 226841]                                                                                             
malloc(): corrupted top size                                                                                                                  

Program received signal SIGABRT, Aborted.                                                                                                     
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50                                                                         
50        return ret;                                                                                                                         
(gdb) bt                                                                                                                                      
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50                                                                     
#1  0x00007ffff7dfb895 in __GI_abort () at abort.c:79                                                                                         
#2  0x00007ffff7e568c7 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7f67e1d "%s\n")                                  
    at ../sysdeps/posix/libc_fatal.c:155                                                                                                      
#3  0x00007ffff7e5ddec in malloc_printerr (str=str@entry=0x7ffff7f6610c "malloc(): corrupted top size") at malloc.c:5347                      
#4  0x00007ffff7e614d7 in _int_malloc (av=av@entry=0x7ffff7f999e0 <main_arena>, bytes=bytes@entry=1024) at malloc.c:4107                      
#5  0x00007ffff7e62534 in __GI___libc_malloc (bytes=1024) at malloc.c:3058                                                                    
#6  0x00007ffff7e4bfc4 in __GI__IO_file_doallocate (fp=0x7ffff7f9a500 <_IO_2_1_stdout_>) at filedoalloc.c:101                                 
#7  0x00007ffff7e5ad20 in __GI__IO_doallocbuf (fp=0x7ffff7f9a500 <_IO_2_1_stdout_>) at libioP.h:948                                           
#8  __GI__IO_doallocbuf (fp=fp@entry=0x7ffff7f9a500 <_IO_2_1_stdout_>) at genops.c:342                                                        
#9  0x00007ffff7e59eb8 in _IO_new_file_overflow (f=0x7ffff7f9a500 <_IO_2_1_stdout_>, ch=-1) at fileops.c:745                                  
#10 0x00007ffff7e58f66 in _IO_new_file_xsputn (n=5, data=<optimized out>, f=<optimized out>) at libioP.h:948                                  
#11 _IO_new_file_xsputn (f=0x7ffff7f9a500 <_IO_2_1_stdout_>, data=<optimized out>, n=5) at fileops.c:1197                                     
#12 0x00007ffff7e41730 in __vfprintf_internal (s=0x7ffff7f9a500 <_IO_2_1_stdout_>, format=0x403015 "out: %s", ap=ap@entry=0x7fffffffd870,     
    mode_flags=mode_flags@entry=0) at ../libio/libioP.h:948                                                                                   
#13 0x00007ffff7e2e43f in __printf (format=<optimized out>) at printf.c:33                                                                    
#14 0x000000000040169f in cat ()                                                                                                              
#15 0x000000000040269e in main ()                                    

I haven't debugged further

DavRack commented 4 years ago

Ok, let me try to replicate

pstonham commented 4 years ago

Getting the same issue on arch

matosjoaops commented 4 years ago

I think the problem is in the cat function in arrayFunctions.h, 50 bytes are allocated regardless of the value of s. If s > 50, it won't work. Is there a particular reason for not using strcat @DavRack?

DavRack commented 4 years ago

@gnufied @pstonham please post the output of skr --init, im working on a better way to handle strings in skr

DavRack commented 4 years ago

I've implemented a fix, pls check if you still get the error

DavRack commented 4 years ago

@iconocles did you use the lattest commit?

iconocles commented 4 years ago

Yeah I posted my feedback just after you implemented the fix; you can close this issue now, I'm no longer getting malloc(): corrupted top size.

pstonham commented 4 years ago

Great work, that fixed it for me

DavRack commented 4 years ago

Awesome!