Description: TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. . gcl (2.6.12-23) unstable; urgency=medium . * Version_2_6_13pre28 Author: Camm Maguire --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: , Bug: Bug-Debian: https://bugs.debian.org/ Bug-Ubuntu: https://launchpad.net/bugs/ Forwarded: Reviewed-By: Last-Update: --- gcl-2.6.12.orig/h/linux.h +++ gcl-2.6.12/h/linux.h @@ -132,20 +132,18 @@ do { int c = 0; \ #include #include -#define GET_FULL_PATH_SELF(a_) do {\ - char b[20];\ - static char q[PATH_MAX];\ - struct stat ss;\ - if (snprintf(b,sizeof(b),"/proc/%d/exe",getpid())<=0)\ - error("Cannot write proc exe pathname");\ - if (stat(b,&ss)) \ - (a_)=argv[0];\ - else {\ - if (!realpath(b,q)) \ - error("realpath error");\ - (a_)=q;\ - }\ -} while(0) +#define GET_FULL_PATH_SELF(a_) do { \ + static char q[PATH_MAX]; \ + const char *s="/proc/self/exe"; \ + struct stat ss; \ + if (stat(s,&ss)) \ + (a_)=argv[0]; \ + else { \ + if (!realpath(s,q)) \ + error("realpath error"); \ + (a_)=q; \ + } \ + } while(0) #define UC(a_) ((ucontext_t *)a_) --- gcl-2.6.12.orig/h/unrandomize.h +++ gcl-2.6.12/h/unrandomize.h @@ -23,6 +23,7 @@ int i,j,k; char **n,**a; void *v; + argv[0]="/proc/self/exe"; for (i=j=0;argv[i];i++) j+=strlen(argv[i])+1; for (k=0;envp[k];k++) --- gcl-2.6.12.orig/o/alloc.c +++ gcl-2.6.12/o/alloc.c @@ -351,7 +351,8 @@ resize_hole(ufixnum hp,enum type tp,bool if (!in_placep && ((new_start<=start && starts.s_dbind != Cnil) + emsg("Toggling relblock when resizing hole to %lu\n",hp); tm_table[t_relocatable].tm_adjgbccnt--; GBC(t_relocatable); return resize_hole(hp,tp,in_placep); @@ -387,7 +388,8 @@ alloc_page(long n) { d=d<0 ? 0 : d; d=(available_pages/3)s.s_dbind != Cnil) + emsg("Hole overrun\n"); resize_hole(d+nn,t_relocatable,0); @@ -857,7 +859,8 @@ add_pages(struct typemanager *tm,fixnum case t_relocatable: if (rb_high() && m>((rb_start-heap_end)>>PAGEWIDTH)) { - emsg("Moving relblock low before expanding relblock pages\n"); + if (sSAnotify_gbcA->s.s_dbind != Cnil) + emsg("Moving relblock low before expanding relblock pages\n"); tm_table[t_relocatable].tm_adjgbccnt--; GBC(t_relocatable); } @@ -1652,22 +1655,15 @@ DEFUN_NEW("GPROF-QUIT",object,fSgprof_qu if (!gprof_on) return Cnil; - if (!getcwd(b,sizeof(b))) - FEerror("Cannot get working directory", 0); - if (chdir(P_tmpdir)) - FEerror("Cannot change directory to tmpdir", 0); + massert(getcwd(b,sizeof(b))); + massert(!chdir(P_tmpdir)); _mcleanup(); - if (snprintf(b1,sizeof(b1),"gprof %s",kcl_self)<=0) - FEerror("Cannot write gprof command line", 0); - if (!(pp=popen(b1,"r"))) - FEerror("Cannot open gprof pipe", 0); + massert(snprintf(b1,sizeof(b1),"gprof %s",kcl_self)>0); + massert((pp=popen(b1,"r"))); while ((n=fread(b1,1,sizeof(b1),pp))) - if (!fwrite(b1,1,n,stdout)) - FEerror("Cannot write gprof output",0); - if (pclose(pp)<0) - FEerror("Cannot close gprof pipe", 0); - if (chdir(b)) - FEerror("Cannot restore working directory", 0); + massert(fwrite(b1,1,n,stdout)); + massert(pclose(pp)>=0); + massert(!chdir(b)); gprof_on=0; return Cnil; @@ -1785,28 +1781,37 @@ static char *baby_malloc(n) bool writable_malloc=0; -void * -malloc(size_t size) { - - static bool in_malloc; - - if (in_malloc) - return NULL; - in_malloc=1; +static void * +malloc_internal(size_t size) { - if (!gcl_alloc_initialized) - gcl_init_alloc(&size); #ifdef CAN_UNRANDOMIZE_SBRK - else if (!gcl_unrandomized) - return sbrk(size); + if (core_end && core_end!=sbrk(0))/*malloc before main in saved_image*/ + return sbrk(size);/*will never get to gcl_init_alloc, so brk point irrelevant*/ #endif - + if (!gcl_alloc_initialized) { + static bool recursive_malloc; + if (recursive_malloc) + error("Bad malloc"); + recursive_malloc=1; + gcl_init_alloc(&size); + recursive_malloc=0; + } + CHECK_INTERRUPT; malloc_list = make_cons(alloc_simple_string(size), malloc_list); malloc_list->c.c_car->st.st_self = alloc_contblock(size); malloc_list->c.c_car->st.st_adjustable=writable_malloc; + return(malloc_list->c.c_car->st.st_self); + +} + +void * +malloc(size_t size) { + + void *v=malloc_internal(size);; + /* FIXME: this is just to handle clean freeing of the monstartup memory allocated automatically on raw image startup. In saved images, monstartup memory is only @@ -1814,12 +1819,11 @@ malloc(size_t size) { #ifdef GCL_GPROF if (raw_image && size>(textend-textstart) && !initial_monstartup_pointer) { massert(!atexit(gprof_cleanup)); - initial_monstartup_pointer=malloc_list->c.c_car->st.st_self; + initial_monstartup_pointer=v; } #endif - in_malloc=0; - return(malloc_list->c.c_car->st.st_self); + return v; } --- gcl-2.6.12.orig/o/error.c +++ gcl-2.6.12/o/error.c @@ -35,7 +35,7 @@ object sSterminal_interrupt; void assert_error(const char *a,unsigned l,const char *f,const char *n) { - if (!raw_image) + if (!raw_image && core_end && core_end==sbrk(0)) FEerror("The assertion ~a on line ~a of ~a in function ~a failed",4, make_simple_string(a),make_fixnum(l), make_simple_string(f),make_simple_string(n)); --- gcl-2.6.12.orig/o/gbc.c +++ gcl-2.6.12/o/gbc.c @@ -1170,15 +1170,15 @@ GBC(enum type t) { gc_time=0; #ifdef SGC - printf("[%s for %ld %s pages..", - (sgc_enabled ? "SGC" : "GC"), - (sgc_enabled ? sgc_count_type(t) : tm_of(t)->tm_npage), - (tm_table[(int)t].tm_name)+1); + emsg("[%s for %ld %s pages..", + (sgc_enabled ? "SGC" : "GC"), + (sgc_enabled ? sgc_count_type(t) : tm_of(t)->tm_npage), + (tm_table[(int)t].tm_name)+1); #else - printf("[%s for %ld %s pages..", - ("GC"), - (tm_of(t)->tm_npage), - (tm_table[(int)t].tm_name)+1); + emsg("[%s for %ld %s pages..", + ("GC"), + (tm_of(t)->tm_npage), + (tm_table[(int)t].tm_name)+1); #endif #ifdef SGC @@ -1349,10 +1349,9 @@ GBC(enum type t) { if (sSAnotify_gbcA->s.s_dbind != Cnil) { if (gc_recursive) - fprintf(stdout, "(T=...).GC finished]\n"); + emsg("(T=...).GC finished]\n"); else - fprintf(stdout, "(T=%d).GC finished]\n",gc_start); - fflush(stdout); + emsg("(T=%d).GC finished]\n",gc_start); } --- gcl-2.6.12.orig/o/main.c +++ gcl-2.6.12/o/main.c @@ -205,21 +205,21 @@ get_proc_meminfo_value_in_pages(const ch return n>>(PAGEWIDTH-10); } +#include + static ufixnum get_phys_pages_no_malloc(char freep) { - return freep ? - get_proc_meminfo_value_in_pages("MemFree:")+ - get_proc_meminfo_value_in_pages("Buffers:")+ - get_proc_meminfo_value_in_pages("Cached:") : - get_proc_meminfo_value_in_pages("MemTotal:"); + struct sysinfo s; + sysinfo(&s); + return (freep ? s.freeram : s.totalram)>>PAGEWIDTH; } #endif static ufixnum -get_phys_pages(char freep) { +get_phys_pages1(char freep) { return get_phys_pages_no_malloc(freep); @@ -313,7 +313,7 @@ update_real_maxpage(void) { } massert(!mbrk(cur)); - phys_pages=ufmin(get_phys_pages(0)+page(beg),real_maxpage)-page(beg); + phys_pages=ufmin(get_phys_pages1(0)+page(beg),real_maxpage)-page(beg); get_gc_environ(); setup_maxpages(mem_multiple); @@ -412,10 +412,6 @@ DEFVAR("*CODE-BLOCK-RESERVE*",sSAcode_bl #define HAVE_GCL_CLEANUP -#ifdef CAN_UNRANDOMIZE_SBRK -bool gcl_unrandomized=FALSE; -#endif - void gcl_cleanup(int gc) { @@ -442,10 +438,6 @@ gcl_cleanup(int gc) { cs_org=0; initial_sbrk=core_end; -#ifdef CAN_UNRANDOMIZE_SBRK - gcl_unrandomized=FALSE; -#endif - } close_pool(); @@ -460,7 +452,6 @@ main(int argc, char **argv, char **envp) #include #include #include "unrandomize.h" - gcl_unrandomized=TRUE; #endif gcl_init_alloc(&argv); --- gcl-2.6.12.orig/o/sfaslelf.c +++ gcl-2.6.12/o/sfaslelf.c @@ -181,8 +181,7 @@ relocate(Sym *sym1,void *v,ul a,ul start #include RELOC_H default: - emsg("Unknown reloc type %lu\n", tp); - massert(tp&~tp); + massert(!emsg("Unknown reloc type %lu\n", tp)); } --- gcl-2.6.12.orig/o/sgbc.c +++ gcl-2.6.12/o/sgbc.c @@ -789,10 +789,8 @@ sgc_start(void) { sgc_enabled=1; if (memory_protect(1)) sgc_quit(); - if (sSAnotify_gbcA->s.s_dbind != Cnil) { - printf("[SGC on]"); - fflush(stdout); - } + if (sSAnotify_gbcA->s.s_dbind != Cnil) + emsg("[SGC on]"); sSAoptimize_maximum_pagesA->s.s_dbind=omp; @@ -826,7 +824,7 @@ sgc_quit(void) { memory_protect(0); if(sSAnotify_gbcA->s.s_dbind != Cnil) - printf("[SGC off]"); fflush(stdout); + emsg("[SGC off]"); if (sgc_enabled==0) return 0;