From octave-maintainers-request at bevo dot che dot wisc dot edu Fri Jun 25 10:55:25 1999 Subject: Unidentified subject! From: Alex Stark To: octave-maintainers at bevo dot che dot wisc dot edu, stark@pc14.niss.org Date: Fri, 25 Jun 1999 11:51:28 -0400 To: octave-maintainers at bevo dot che dot wisc dot edu Cc: stark Subject: Simple (?) recursive printing seg fault Bug report for Octave 2.0.13.90 configured for i386-redhat-linux-gnu Description: ----------- * A fairly straightforward recursive procedure for printing a recursive data structure (binary tree) has given me a segmentation fault. It should be self-explanatory otherwise. Repeat-By: --------- (This may be caused by the warnings. I am trying to find out how to switch this off..., or I can wait an hour until the server/desktop daylight saving mismatch is avoided. Note therefore, that my computer thinks that treeprnt `was' written an hour in the future.) Note: it is possible that you would get a different output if the random number generator changes. For this a and b(a) as shown below, the output string should, I think, be `(((((7,5),1),2),(8,3)),(6,4))' if I have the code right. (But it shouldn't crash.) I enclose a transcript, including some Redhat rpm information, and the two files below: ---------------------Transcript octave:1> rand('seed',0);[a b]=treegen(8);[a b(a)],treeprnt(a,b, 15,2) ans = 6 4 7 5 8 3 10 1 12 2 13 11 14 9 warning: time stamp for `/mnt/niss/phylo/bambe/protease/treegen.m' is in the future warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 7,warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 5),warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 1),warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 2),warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future (warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 8,warning: time stamp for `/mnt/niss/phylo/bambe/protease/treeprnt.m' is in the future 3))error: Segmentation fault -- stopping myself... attempting to save variables to `octave-core'... error: attempted clean up apparently failed -- aborting... Abort [protease]$ rpm -qi octave Name : octave Distribution: PowerTools Version : 2.0.13.90 Vendor: Red Hat Software Release : 1 Build Date: Mon Oct 26 22:59:48 1998 Install date: Tue Mar 23 11:33:43 1999 Build Host: porky.redhat.com Group : Applications/Math Source RPM: octave-2.0.13.90-1.src.rpm Size : 13260135 License: GPL Packager : Red Hat Software ---------------------treegen.m function [nodelist, pairings] = treegen(k, choicelist) % usage: [nodelist, pairings] = treegen(k, choicelist) % [nodelist, pairings] = treegen(k) % % Generate a tree in node/leaf-pair format either randomly % or using a list of choices. % % k is the number of leaves % choicelist is a vector of numbers, % the 1st containing 1 % the 2nd from 1 to 3 % the 3rd from 1 to 5 % ... % the last from 1 to 2k-3 % This can be used to exhaustively generate trees. % If not given, choicelist is randomly generated % % pairings say which node/leaf is paired with each other node/leaf % (sibling pairs, that is) % % nodelist says which is the largest-numbered child node/leaf for % nodes k+1 through 2k-1 % % J Alex Stark, NISS, 1999-06-25 if (nargin<2) choicelist = ceil(rand(k-1,1).*(1:2:2*k-3)'); end NN=2*(k-1); remlist=(1:NN)'; pairings=-remlist; % -ve means index into remlist for i=NN:-2:2 l=remlist(i); choice = remlist(choicelist(i/2)); % Remove node choice from remlist (node l is just discarded) locrem=-pairings(choice); switchnode = remlist(i-1); remlist(locrem)=switchnode; pairings(switchnode)=-locrem; pairings(l)=choice; pairings(choice)=l; end remlist = remlist*0; nodelist=zeros(k-1,1); l=NN; for i=k-1:-1:1 while (remlist(l)>0) l=l-1; end %printf('(%g,%g)\n', l, pairings(l)); nodelist(i)=l; remlist(l)=1; remlist(pairings(l))=1; end %[nodelist pairings(nodelist)] ---------------------treeprnt.m function treeprnt(nodelist, pairings, j, FILEH) % usage: treeprnt(nodelist, pairings, j, FILEH) % treeprnt(nodelist, pairings, j) % % Print a tree in nodelist-pairings format (for which, see % treegen.m), starting at node j. This calls itself recursively: % for the whole tree use j=2k-1, where k is the number of leaves. % The tree is printed to standard output if no file handle is % given. % % J Alex Stark, NISS, 1999-06-25 if (nargin<4) FILEH = 1; end k=length(nodelist)+1; if (j<=k) fprintf(FILEH,'%g',j); else fprintf(FILEH,'('); treeprnt(nodelist, pairings, nodelist(j-k), FILEH); fprintf(FILEH,','); treeprnt(nodelist, pairings, pairings(nodelist(j-k)), FILEH); fprintf(FILEH,')'); end --------------------- Configuration (please do not edit this section): ----------------------------------------------- uname output: Linux pc14.niss.org 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998 i686 unknown configure opts: --prefix=/usr --with-g77 --enable-dl --enable-shared --enable-rpath --enable-lite-kernel --enable-picky-flags i386-redhat-linux Fortran compiler: g77 FFLAGS: -O F2C: F2CFLAGS: FLIBS: -L/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.90.29 -L/usr/i386-redhat-linux/lib -lf2c -lm CPPFLAGS: INCFLAGS: -I/usr/include -I/usr/include/octave-2.0.13.90 C compiler: gcc, version 2.7.2.3 CFLAGS: -DHAVE_CONFIG_H -mieee-fp -O2 -m486 -fno-strength-reduce CPICFLAG: -fPIC C++ compiler: c++, version 2.90.29 980515 (egcs-1.0.3 release) CXXFLAGS: -DHAVE_CONFIG_H -mieee-fp -fno-rtti -fno-exceptions -fno-implicit-templates -O2 -m486 -fno-strength-reduce CXXPICFLAG: -fPIC LDFLAGS: -g LIBFLAGS: -L/usr/lib/octave-2.0.13.90 RLD_FLAG: -Xlinker -rpath -Xlinker /usr/lib/octave-2.0.13.90 TERMLIBS: -lncurses LIBS: LEXLIB: LIBPLPLOT: LIBDLFCN: DEFS: -DOCTAVE_SOURCE=1 -DSEPCHAR=':' -DSEPCHAR_STR=":" -DUSE_READLINE=1 -DCXX_NEW_FRIEND_TEMPLATE_DECL=1 -DF77_APPEND_UNDERSCORE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MES=1 User-preferences (please do not edit this section): -------------------------------------------------- EDITOR = "emacs" EXEC_PATH = ":/home/stark/local/bin:/home/stark/devel/bin:/home/stark/rpmlocal/bin:/home/stark/local/bin:/home/stark/devel/bin:/home/stark/rpmlocal/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:.:/usr/X11R6/bin:." IMAGEPATH = ".:/usr/share/octave/2.0.13.90/imagelib//" INFO_FILE = "/usr/info/octave.info" INFO_PROGRAM = "info" LOADPATH = ".:/usr/libexec/octave/site/oct/i386-redhat-linux-gnu//:/usr/share/octave/site/m//:/usr/libexec/octave/2.0.13.90/oct/i386-redhat-linux-gnu//:/usr/share/octave/2.0.13.90/m//" PAGER = "less" PS1 = "\\s:\\#> " PS2 = "> " PS4 = "+ " auto_unload_dot_oct_files = 0 automatic_replot = 0 beep_on_error = 0 completion_append_char = " " default_eval_print_flag = 1 # default_global_variable_value = default_return_value = [] default_save_format = "ascii" define_all_return_values = 0 do_fortran_indexing = 0 echo_executing_commands = 0 empty_list_elements_ok = "warn" fixed_point_format = 0 gnuplot_binary = "gnuplot" gnuplot_has_frames = 0 gnuplot_has_multiplot = 0 history_file = "/home/stark/.octave_hist" history_size = 1024 ignore_function_time_stamp = "system" implicit_num_to_str_ok = 0 implicit_str_to_num_ok = 0 initialize_global_variables = 0 max_recursion_depth = 256 ok_to_lose_imaginary_part = "warn" output_max_field_width = 10 output_precision = 5 page_output_immediately = 0 page_screen_output = 1 prefer_column_vectors = 1 prefer_zero_one_indexing = 0 print_answer_id_name = 1 print_empty_dimensions = 1 propagate_empty_matrices = 1 resize_on_range_error = 1 return_last_computed_value = 0 save_precision = 15 saving_history = 1 silent_functions = 0 split_long_rows = 1 string_fill_char = " " struct_levels_to_print = 2 suppress_verbose_help_message = 0 treat_neg_dim_as_zero = 0 warn_assign_as_truth_value = 1 warn_comma_in_global_decl = 1 warn_divide_by_zero = 1 warn_function_name_clash = 1 warn_missing_semicolon = 0 warn_reload_forces_clear = 1 warn_variable_switch_label = 0 whitespace_in_literal_matrix =