diff --git a/clisp-encoding-leak.patch b/clisp-encoding-leak.patch new file mode 100644 index 0000000..f2b939a --- /dev/null +++ b/clisp-encoding-leak.patch @@ -0,0 +1,10 @@ +--- src/encoding.d.orig 2024-12-28 00:47:59.000000000 -0700 ++++ src/encoding.d 2025-02-04 20:28:22.743346018 -0700 +@@ -2592,6 +2592,7 @@ local maygc object encoding_from_name (c + pushSTACK(STACK_0); + } + } ++ free(name); + #else + unused const_name; unused context; + pushSTACK(unbound); /* :charset */ diff --git a/clisp-iconv-close.patch b/clisp-iconv-close.patch new file mode 100644 index 0000000..db553ad --- /dev/null +++ b/clisp-iconv-close.patch @@ -0,0 +1,38 @@ +--- src/stream.d.orig 2024-12-28 00:47:59.000000000 -0700 ++++ src/stream.d 2025-02-07 11:47:28.448086694 -0700 +@@ -4239,6 +4239,9 @@ global uintL iconv_wcslen (object encodi + != (size_t)(-1)) { + inptr += sizeof(chart); insize -= sizeof(chart); + } else { ++ var int saved_errno = errno; ++ iconv_close(cd); ++ errno = saved_errno; + if (errno != EILSEQ) { + ANSIC_error(); + } else { +@@ -4247,6 +4250,7 @@ global uintL iconv_wcslen (object encodi + } + } + } else { ++ iconv_close(cd); + end_system_call(); + error_unencodable(encoding,*(const chart*)inptr); + } +@@ -4317,6 +4321,9 @@ global void iconv_wcstombs (object encod + if (iconv(cd,&inptr1,&insize1,&outptr,&outsize) != (size_t)(-1)) { + inptr += sizeof(chart); insize -= sizeof(chart); + } else { ++ var int saved_errno = errno; ++ iconv_close(cd); ++ errno = saved_errno; + if (errno != EILSEQ) { + ANSIC_error(); + } else { +@@ -4325,6 +4332,7 @@ global void iconv_wcstombs (object encod + } + } + } else { ++ iconv_close(cd); + end_system_call(); + error_unencodable(encoding,*(const chart*)inptr); + } diff --git a/clisp-undefined-behavior.patch b/clisp-undefined-behavior.patch new file mode 100644 index 0000000..309c8b2 --- /dev/null +++ b/clisp-undefined-behavior.patch @@ -0,0 +1,46 @@ +See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118779 + +--- src/package.d.orig 2024-12-28 00:47:59.000000000 -0700 ++++ src/package.d 2025-02-07 12:00:00.646094825 -0700 +@@ -188,12 +188,12 @@ local maygc object rehash_symtab (object + first process the symbols, that sit in lists + (maybe Conses become free): */ + { +- var gcv_object_t* offset = 0; /* offset = sizeof(gcv_object_t)*index */ ++ var aint offset = 0; /* offset = sizeof(gcv_object_t)*index */ + var uintC count = oldsize; + do { + var object oldentry = /* entry with number index in oldtable */ + *(gcv_object_t*)(pointerplus(&TheSvector(STACK_2)->data[0], +- (aint)offset)); ++ offset)); + if (consp(oldentry)) /* this time process only non-empty symbol-lists */ + do { + pushSTACK(Cdr(oldentry)); /* save rest-list */ +@@ -205,22 +205,22 @@ local maygc object rehash_symtab (object + newinsert(Car(oldentry),newsize); + oldentry = popSTACK(); /* rest-list */ + } while (consp(oldentry)); +- offset++; ++ offset += sizeof(gcv_object_t); + } while (--count); + } + { /* then process symbols, that sit there collision-free: */ +- var gcv_object_t* offset = 0; /* offset = sizeof(gcv_object_t)*index */ ++ var aint offset = 0; /* offset = sizeof(gcv_object_t)*index */ + var uintC count; + dotimespC(count,oldsize, { + var object oldentry = /* entry with number index in oldtable */ + *(gcv_object_t*)(pointerplus(&TheSvector(STACK_2)->data[0], +- (aint)offset)); ++ offset)); + if (!listp(oldentry)) { /* this time process only symbols /= NIL */ + pushSTACK(oldentry); /* dummy, so that the stack is fine */ + newinsert(oldentry,newsize); /* enter into the new table */ + skipSTACK(1); + } +- offset++; ++ offset += sizeof(gcv_object_t); + }); + } + /* stack layout: tab, oldtable, free-conses, newtable. */ diff --git a/clisp.spec b/clisp.spec index 6e3928a..73f38cb 100644 --- a/clisp.spec +++ b/clisp.spec @@ -44,6 +44,14 @@ Patch1: %{name}-register-volatile.patch Patch2: %{name}-pts-access.patch # Do not call the deprecated siginterrupt function Patch3: %{name}-siginterrupt.patch +# Fix an iconv leak in stream.d +Patch4: %{name}-iconv-close.patch +# Fix a memory leak in encoding.d +# https://gitlab.com/gnu-clisp/clisp/-/merge_requests/11 +Patch5: %{name}-encoding-leak.patch +# Fix undefined behavior in rehash_symtab +# https://gitlab.com/gnu-clisp/clisp/-/merge_requests/12 +Patch6: %{name}-undefined-behavior.patch # Work around a problem inlining a function on ppc64le # See https://bugzilla.redhat.com/show_bug.cgi?id=2049371 @@ -136,8 +144,11 @@ cp -p %{SOURCE2} %{SOURCE3} src/po cp -p src/build-aux/config.rpath config.rpath.orig sed -i -e 's/${wl}-rpath ${wl}/-L/g' src/build-aux/config.rpath -# Fix modules that need access to symbols in libgnu.a -sed -i 's/\(${GLLIB_A}\) \(${LIBS}\)/-Wl,--whole-archive \1 -Wl,--no-whole-archive \2 -ldl/' src/makemake.in +# Do not use -Werror, or we get build failures on every new gcc version +sed -i '/CFLAGS -Werror/d' modules/berkeley-db/configure + +# Do not override our choice of optimization flags +sed -i "/CFLAGS/s/'-O'/''/;/Z_XCFLAGS/s/' -O'//" src/makemake.in # When building modules, put -Wl,--as-needed before the libraries to link sed -i "s/CC='\${CC}'/CC='\${CC} -Wl,--as-needed'/" src/makemake.in @@ -185,9 +196,9 @@ sed -i 's/9090/9096/g' tests/socket.tst --with-ffcall \ --config \ build \ - CPPFLAGS="-I/usr/include/libsvm" \ - CFLAGS="%{build_cflags} -Wa,--noexecstack" \ - LDFLAGS="-Wl,--as-needed -Wl,-z,relro -Wl,-z,noexecstack" + CPPFLAGS='-I/usr/include/libsvm' \ + CFLAGS='%{build_cflags} -Wa,--noexecstack' \ + LDFLAGS='-Wl,--as-needed -Wl,-z,relro -Wl,-z,noexecstack' cd build # Workaround libtool reordering -Wl,--as-needed after all the libraries. @@ -441,6 +452,11 @@ make -C build base-mod-check %changelog +* Fri Feb 7 2025 Jerry James - 2.49.95-3 +- Add patch to fix undefined behavior (rhbz#2339979) +- Add two patches to fix memory leaks +- Do not force -O1 + * Thu Jan 16 2025 Fedora Release Engineering - 2.49.95-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild