unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Bill Schottstaedt" <bil@ccrma.Stanford.EDU>
To: bug-guile@gnu.org
Subject: guile 1.9.0 scm_read_hash_extend gc trouble
Date: Sun, 21 Jun 2009 05:10:09 -0700	[thread overview]
Message-ID: <20090621120823.M97037@ccrma.Stanford.EDU> (raw)

In the new Guile (1.9.0), the scsh-derived code to implement #|..|# block
comment processing triggers either a glibc memory complaint
or a segfault.  (The following code is slightly translated, so
I may have introduced typos, but the basic idea has worked for
maybe 10 years):

static SCM g_skip_block_comment(SCM ch, SCM port)
{
  int bang_seen = 0;
  while (true)
    {
      int c;
      c = scm_getc(port);
      if (c == EOF)
	{
	  fprintf(stderr, "unterminated `#| ... |#' comment");
	  return(SCM_BOOL_F);
	}
      if (c == '|')
	bang_seen = 1;
      else 
	{
	  if ((c == '#') && (bang_seen))
	    return(SCM_BOOL_F);
	  else bang_seen = 0;
	}
    }
  return(SCM_BOOL_F);
}


Then call scm_read_hash_extend with "|" to activate it.  If I have
a file such as:

#|
;;; a test
|#


(or any other file with such a comment), and read it in snd/guile:


*** glibc detected *** ../guile-snd/snd: free(): invalid next size (normal): 0x098c4730 ***
======= Backtrace: =========
/lib/libc.so.6[0x39e394]
/lib/libc.so.6(cfree+0x96)[0x3a0346]
/usr/local/lib/libguile.so.18(scm_gc_free+0x3c)[0x4006a59c]
/usr/local/lib/libguile.so.18[0x4008fb6a]
/usr/local/lib/libguile.so.18(scm_close_port+0xa5)[0x4008fc35]
/usr/local/lib/libguile.so.18(scm_primitive_load+0xdd)[0x4007ccdd]
/usr/local/lib/libguile.so.18(scm_c_primitive_load+0x25)[0x4007d135]
../guile-snd/snd[0x8160d46]
/usr/local/lib/libguile.so.18(scm_c_with_throw_handler+0x10b)[0x400c64db]
/usr/local/lib/libguile.so.18(scm_internal_lazy_catch+0x41)[0x400c6671]
/usr/local/lib/libguile.so.18[0x400c674f]
/usr/local/lib/libguile.so.18(scm_c_catch+0x28d)[0x400c69ed]
/usr/local/lib/libguile.so.18(scm_internal_catch+0x49)[0x400c6c39]
/usr/local/lib/libguile.so.18(scm_internal_stack_catch+0x4b)[0x400c6cfb]
../guile-snd/snd(snd_catch_any+0x42)[0x8161232]
../guile-snd/snd(snd_load_file+0xac)[0x816159c]
../guile-snd/snd(handle_next_startup_arg+0x29f)[0x8144dbf]
../guile-snd/snd(snd_doit+0x60d)[0x81cd26d]
/usr/local/lib/libguile.so.18[0x400788a6]
/usr/local/lib/libguile.so.18[0x4004e072]
/usr/local/lib/libguile.so.18(scm_c_catch+0x28d)[0x400c69ed]
/usr/local/lib/libguile.so.18[0x4004e692]
/usr/local/lib/libguile.so.18(scm_c_with_continuation_barrier+0x53)[0x4004e773]
/usr/local/lib/libguile.so.18[0x400c539c]
/usr/local/lib/libguile.so.18(scm_with_guile+0x2e)[0x400c54ae]
/usr/local/lib/libguile.so.18(scm_boot_guile+0x3f)[0x4007883f]
../guile-snd/snd(main+0x32)[0x8159782]
/lib/libc.so.6(__libc_start_main+0xe5)[0x3456d5]
../guile-snd/snd[0x8065621]
======= Memory map: ========
0030a000-0032a000 r-xp 00000000 fd:00 13018312   /lib/ld-2.9.so
0032b000-0032c000 r-xp 00020000 fd:00 13018312   /lib/ld-2.9.so
0032c000-0032d000 rwxp 00021000 fd:00 13018312   /lib/ld-2.9.so
0032f000-0049d000 r-xp 00000000 fd:00 13018313   /lib/libc-2.9.so
0049d000-0049f000 r-xp 0016e000 fd:00 13018313   /lib/libc-2.9.so
0049f000-004a0000 rwxp 00170000 fd:00 13018313   /lib/libc-2.9.so
004a0000-004a3000 rwxp 004a0000 00:00 0 
004a5000-004cc000 r-xp 00000000 fd:00 13018324   /lib/libm-2.9.so
004cc000-004cd000 r-xp 00026000 fd:00 13018324   /lib/libm-2.9.so
004cd000-004ce000 rwxp 00027000 fd:00 13018324   /lib/libm-2.9.so
004d0000-004d3000 r-xp 00000000 fd:00 13018319   /lib/libdl-2.9.so
004d3000-004d4000 r-xp 00002000 fd:00 13018319   /lib/libdl-2.9.so
004d4000-004d5000 rwxp 00003000 fd:00 13018319   /lib/libdl-2.9.so
004d7000-004ed000 r-xp 00000000 fd:00 13018314   /lib/libpthread-2.9.so
004ed000-004ee000 r-xp 00015000 fd:00 13018314   /lib/libpthread-2.9.so
004ee000-004ef000 rwxp 00016000 fd:00 13018314   /lib/libpthread-2.9.so
004ef000-004f1000 rwxp 004ef000 00:00 0 
009d4000-009e1000 r-xp 00000000 fd:00 13018327   /lib/libgcc_s-4.3.2-20081105.so.1
009e1000-009e2000 rwxp 0000c000 fd:00 13018327   /lib/libgcc_s-4.3.2-20081105.so.1
055c4000-055ce000 r-xp 00000000 fd:00 13018344   /lib/libcrypt-2.9.so
055ce000-055cf000 r-xp 00009000 fd:00 13018344   /lib/libcrypt-2.9.so
055cf000-055d0000 rwxp 0000a000 fd:00 13018344   /lib/libcrypt-2.9.so
055d0000-055f7000 rwxp 055d0000 00:00 0 
08048000-082eb000 r-xp 00000000 fd:00 21537167   /home/bil/guile-snd/snd
082eb000-082f1000 rwxp 002a3000 fd:00 21537167   /home/bil/guile-snd/snd
082f1000-082f3000 rwxp 082f1000 00:00 0 
0977f000-098db000 rwxp 0977f000 00:00 0          [heap]
40000000-40001000 r-xp 40000000 00:00 0          [vdso]
40001000-40002000 rwxp 40001000 00:00 0 
40002000-40005000 r-xs 00000000 fd:00 14231648   /usr/local/lib/guile/1.9/ccache/ice-
9/r4rs.go
40005000-40007000 r-xs 00000000 fd:00 14231672   /usr/local/lib/guile/1.9/ccache/ice-
9/posix.go
40007000-40009000 r-xs 00000000 fd:00 14231666   /usr/local/lib/guile/1.9/ccache/ice-
9/networking.go
40009000-4000c000 r-xs 00000000 fd:00 14231696   /usr/local/lib/guile/1.9/ccache/ice-
9/deprecated.go
4000c000-4000d000 r-xp 02388000 fd:00 13649054   /usr/lib/locale/locale-archive
4000d000-40012000 r-xs 00000000 fd:00 14231669   /usr/local/lib/guile/1.9/ccache/ice-
9/optargs.go
4001e000-4010c000 r-xp 00000000 fd:00 3154070    /usr/local/lib/libguile.so.18.0.0
4010c000-40110000 rwxp 000ee000 fd:00 3154070    /usr/local/lib/libguile.so.18.0.0
40110000-4011b000 rwxp 40110000 00:00 0 
4011b000-40223000 r-xp 00000000 fd:00 3154130    /usr/local/lib/libunistring.so.0.0.0
40223000-40225000 rwxp 00108000 fd:00 3154130    /usr/local/lib/libunistring.so.0.0.0
40225000-40270000 r-xp 00000000 fd:00 3154050    /usr/local/lib/libgmp.so.3.5.0
40270000-40271000 rwxp 0004a000 fd:00 3154050    /usr/local/lib/libgmp.so.3.5.0
40271000-40272000 rwxp 40271000 00:00 0 
40272000-40279000 r-xp 00000000 fd:00 3153921    /usr/local/lib/libltdl.so.7.2.0
40279000-4027a000 rwxp 00006000 fd:00 3153921    /usr/local/lib/libltdl.so.7.2.0
4027a000-4041b000 r-xp 00000000 fd:00 13653194   /usr/local/lib/libgsl.so.0.13.0
4041b000-40425000 rwxp 001a0000 fd:00 13653194   /usr/local/lib/libgsl.so.0.13.0
40425000-4045a000 r-xp 00000000 fd:00 13652488   /usr/local/lib/libgslcblas.so.0.0.0
4045a000-4045b000 rwxp 00035000 fd:00 13652488   /usr/local/lib/libgslcblas.so.0.0.0
4045b000-404a0000 rwxp 4045b000 00:00 0 
404a0000-404cb000 r-xs 00000000 fd:00 14231647   /usr/local/lib/guile/1.9/ccache/ice-
9/boot-9.go
404cb000-40500000 r-xs 00000000 fd:00 14231646   /usr/local/lib/guile/1.9/ccache/ice-
9/psyntax-pp.go
40500000-40700000 r-xp 00000000 fd:00 13649054   /usr/lib/locale/locale-archive
40700000-4073c000 r-xp 0232f000 fd:00 13649054   /usr/lib/locale/locale-archive
40800000-40821000 rwxp 40800000 00:00 0 
40821000-40900000 ---p 40821000 00:00 0 
bfbac000-bfbc1000 rwxp bffeb000 00:00 0          [stack]
Abort (core dumped)


in gdb:

Program received signal SIGABRT, Aborted.
0x40000424 in __kernel_vsyscall ()
Missing separate debuginfos, use: debuginfo-install glibc-2.9-2.i686 libgcc-4.3.2-7.i386
(gdb) where
#0  0x40000424 in __kernel_vsyscall ()
#1  0x0035a450 in raise () from /lib/libc.so.6
#2  0x0035be18 in abort () from /lib/libc.so.6
#3  0x00397fdd in __libc_message () from /lib/libc.so.6
#4  0x0039e394 in malloc_printerr () from /lib/libc.so.6
#5  0x003a0346 in free () from /lib/libc.so.6
#6  0x4006a59c in scm_gc_free (mem=0x8438738, size=92, what=0x400ff274 "port")
    at gc-malloc.c:370
#7  0x4008fb6a in scm_i_remove_port (port=0x841ef58) at ports.c:553
#8  0x4008fc35 in scm_close_port (port=0x841ef58) at ports.c:730
#9  0x4007ccdd in scm_primitive_load (filename=0x83c9410) at load.c:120
#10 0x4007d135 in scm_c_primitive_load (filename=0x84387f0 "/home/bil/cl/g.scm") at load.c:129
#11 0x08160d46 in eval_file_wrapper (data=0x84387f0) at snd-xen.c:979
#12 0x400c64db in scm_c_with_throw_handler (tag=0x104, body=0x8160d30 <eval_file_wrapper>, 
    body_data=0x84387f0, handler=0x400c6370 <ss_handler>, handler_data=0x0, lazy_catch_p=1)
    at throw.c:317
#13 0x400c6671 in scm_internal_lazy_catch (tag=0x104, body=0x8160d30 <eval_file_wrapper>, 
    body_data=0x84387f0, handler=0x400c6370 <ss_handler>, handler_data=0x0) at throw.c:332
#14 0x400c674f in cwss_body (data=0xbfffef48) at throw.c:361
#15 0x400c69ed in scm_c_catch (tag=0x104, body=0x400c6710 <cwss_body>, 
body_data=0xbfffef48, 
    handler=0x8162f00 <snd_catch_scm_error>, handler_data=0x8438470, pre_unwind_handler=0, 
    pre_unwind_handler_data=0x0) at throw.c:242
#16 0x400c6c39 in scm_internal_catch (tag=0x104, body=0x400c6710 <cwss_body>, 
    body_data=0xbfffef48, handler=0x8162f00 <snd_catch_scm_error>, handler_data=0x8438470)
    at throw.c:256
#17 0x400c6cfb in scm_internal_stack_catch (tag=0x104, body=0x8160d30 <eval_file_wrapper>, 
    body_data=0x84387f0, handler=0x8162f00 <snd_catch_scm_error>, handler_data=0x8438470)
    at throw.c:375
#18 0x08161232 in snd_internal_stack_catch () at snd-xen.c:644
#19 snd_catch_any (body=0x8160d30 <eval_file_wrapper>, body_data=0x84387f0, 
    caller=0x8438470 "(load \"g.scm\")") at snd-xen.c:666
#20 0x0816159c in snd_load_file (filename=0xbffff50f "g.scm") at snd-xen.c:1349
#21 0x08144dbf in handle_next_startup_arg (auto_open_ctr=1, auto_open_file_names=0xbffff348, 
    with_title=false, args=2) at snd-main.c:1579
#22 0x081cd26d in snd_doit (argc=3, argv=0xbffff344) at snd-nogui.c:720
#23 0x400788a6 in invoke_main_func (body_data=0xbffff274) at init.c:372
#24 0x4004e072 in c_body (d=0xbffff1c8) at continuations.c:354
#25 0x400c69ed in scm_c_catch (tag=0x104, body=0x4004e060 <c_body>, body_data=0xbffff1c8, 
    handler=0x4004e080 <c_handler>, handler_data=0xbffff1c8, 
    pre_unwind_handler=0x400c5c40 <scm_handle_by_message_noexit>, 
pre_unwind_handler_data=0x0)
    at throw.c:242
#26 0x4004e692 in scm_i_with_continuation_barrier (body=0x4004e060 <c_body>, 
    body_data=0xbffff1c8, handler=0x4004e080 <c_handler>, handler_data=0xbffff1c8, 
    pre_unwind_handler=0x400c5c40 <scm_handle_by_message_noexit>, 
pre_unwind_handler_data=0x0)
    at continuations.c:330
#27 0x4004e773 in scm_c_with_continuation_barrier (func=0x40078860 <invoke_main_func>, 
    data=0xbffff274) at continuations.c:372
#28 0x400c539c in scm_i_with_guile_and_parent (func=0x40078860 <invoke_main_func>, 
    data=0xbffff274, parent=0x0) at threads.c:852
#29 0x400c54ae in scm_with_guile (func=0x40078860 <invoke_main_func>, data=0xbffff274)
    at threads.c:831
#30 0x4007883f in scm_boot_guile (argc=3, argv=0xbffff344, main_func=0x815a120 <snd_main>, 
    closure=0x0) at init.c:355
#31 0x08159782 in main (argc=Cannot access memory at address 0x7358
) at snd.c:518


(gdb) up
#7  0x4008fb6a in scm_i_remove_port (port=0x841ef58) at ports.c:553
553       scm_gc_free (p, sizeof (scm_t_port), "port");
(gdb) p p
$1 = (scm_t_port *) 0x8438738
(gdb) p ((scm_t_port *)p)[0]
$3 = {port = 0x841ef58, revealed = 0, stream = 138074392, file_name = 0x83c9410, 
  line_number = 3, column_number = 0, read_buf = 0x844d800 "#|\n;;; a test\n|#\n", 
  read_pos = 0x844d811 "", read_end = 0x844d811 "", read_buf_size = 4096, 
  saved_read_buf = 0x844d800 "#|\n;;; a test\n|#\n", 
  saved_read_pos = 0x844d802 "\n;;; a test\n|#\n", saved_read_end = 0x844d811 "", 
  saved_read_buf_size = 4096, write_buf = 0x8438780 "", write_pos = 0x8438780 "", 
  write_end = 0x8438781 "", write_buf_size = 1, shortbuf = 0 '\0', rw_random = 1, 
  rw_active = SCM_PORT_NEITHER, putback_buf = 0x83b3270 "\020Ù:\bp\001J", putback_buf_size = 
4}





             reply	other threads:[~2009-06-21 12:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-21 12:10 Bill Schottstaedt [this message]
2009-06-21 15:34 ` guile 1.9.0 scm_read_hash_extend gc trouble Neil Jerram
2009-06-21 15:56   ` Neil Jerram
2009-06-22 17:23     ` Bill Schottstaedt
2009-06-22 23:25       ` Neil Jerram
2009-06-23 19:18         ` Bill Schottstaedt
2009-06-23 23:07           ` Ludovic Courtès
2009-06-27 21:53             ` Neil Jerram
2009-06-27 23:42               ` Ludovic Courtès
2009-06-29 15:02                 ` Ludovic Courtès
2009-06-29 19:18                   ` Neil Jerram
2009-06-24 10:19         ` Bill Schottstaedt
2009-06-22  8:50 ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090621120823.M97037@ccrma.Stanford.EDU \
    --to=bil@ccrma.stanford.edu \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).