From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#20209: GUILE 2.0.11: crash in set_port_filename_x for bytevector ports Date: Thu, 26 Mar 2015 19:02:15 -0400 Message-ID: <87egob8irs.fsf@netris.org> References: <87fv8r1pio.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1427410949 22576 80.91.229.3 (26 Mar 2015 23:02:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 26 Mar 2015 23:02:29 +0000 (UTC) Cc: 20209@debbugs.gnu.org To: David Kastrup Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Mar 27 00:02:19 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YbGn3-0006sT-1W for guile-bugs@m.gmane.org; Fri, 27 Mar 2015 00:02:17 +0100 Original-Received: from localhost ([::1]:46897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbGn2-0001CM-CB for guile-bugs@m.gmane.org; Thu, 26 Mar 2015 19:02:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbGmv-0001CC-G7 for bug-guile@gnu.org; Thu, 26 Mar 2015 19:02:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbGmo-00057A-Fw for bug-guile@gnu.org; Thu, 26 Mar 2015 19:02:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbGmo-000576-CN for bug-guile@gnu.org; Thu, 26 Mar 2015 19:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YbGmo-00005W-3B for bug-guile@gnu.org; Thu, 26 Mar 2015 19:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 26 Mar 2015 23:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20209 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20209-submit@debbugs.gnu.org id=B20209.1427410920330 (code B ref 20209); Thu, 26 Mar 2015 23:02:02 +0000 Original-Received: (at 20209) by debbugs.gnu.org; 26 Mar 2015 23:02:00 +0000 Original-Received: from localhost ([127.0.0.1]:37684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YbGml-00005E-FT for submit@debbugs.gnu.org; Thu, 26 Mar 2015 19:01:59 -0400 Original-Received: from world.peace.net ([50.252.239.5]:38849 ident=hope9) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YbGme-00004z-0r for 20209@debbugs.gnu.org; Thu, 26 Mar 2015 19:01:57 -0400 Original-Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1YbGmW-00039a-Aj; Thu, 26 Mar 2015 19:01:44 -0400 In-Reply-To: <87fv8r1pio.fsf@fencepost.gnu.org> (David Kastrup's message of "Thu, 26 Mar 2015 21:18:23 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7758 Archived-At: David Kastrup writes: > The following code > > > #include > > int main() > { > scm_init_guile (); > SCM str = scm_c_make_bytevector (0); > SCM port = scm_open_bytevector_input_port (str, SCM_UNDEFINED); > scm_set_port_filename_x (port, scm_from_locale_string ("/usr/local/tmp/lilypond/ly/init.ly")); > return 0; > } > > > crashes with the backtrace > > Program terminated with signal SIGSEGV, Segmentation fault. > #0 0xb7699059 in scm_iprlist () from /usr/lib/libguile-2.0.so.22 > (gdb) bt > #0 0xb7699059 in scm_iprlist () from /usr/lib/libguile-2.0.so.22 > #1 0xb7699e95 in ?? () from /usr/lib/libguile-2.0.so.22 > #2 0xb7699153 in scm_iprlist () from /usr/lib/libguile-2.0.so.22 > #3 0xb7699e95 in ?? () from /usr/lib/libguile-2.0.so.22 > #4 0xb7699153 in scm_iprlist () from /usr/lib/libguile-2.0.so.22 > #5 0xb7699e95 in ?? () from /usr/lib/libguile-2.0.so.22 > #6 0xb7698ec9 in scm_prin1 () from /usr/lib/libguile-2.0.so.22 > #7 0xb769a606 in scm_simple_format () from /usr/lib/libguile-2.0.so.22 > #8 0xb76e5f0b in ?? () from /usr/lib/libguile-2.0.so.22 > #9 0xb76e6539 in ?? () from /usr/lib/libguile-2.0.so.22 > #10 0xb76e664c in scm_call_with_vm () from /usr/lib/libguile-2.0.so.22 > #11 0xb764cc67 in scm_apply () from /usr/lib/libguile-2.0.so.22 > #12 0xb764e90e in scm_apply_1 () from /usr/lib/libguile-2.0.so.22 > #13 0xb76cdb7b in scm_throw () from /usr/lib/libguile-2.0.so.22 > #14 0xb76ce04c in scm_ithrow () from /usr/lib/libguile-2.0.so.22 > #15 0xb764b6a3 in scm_error_scm () from /usr/lib/libguile-2.0.so.22 > #16 0xb764b778 in scm_error () from /usr/lib/libguile-2.0.so.22 > #17 0xb764ba22 in scm_wrong_type_arg () from /usr/lib/libguile-2.0.so.22 > #18 0xb76927ca in scm_set_port_filename_x () from /usr/lib/libguile-2.0.so.22 > #19 0x08048723 in main () at nextbug.c:8 > > after outputting > > guile: uncaught throw to wrong-type-arg: (set-port-filename! Wrong > type argument in position ~A: ~S (1 (Segmentation fault (core dumped) The problem turns out to be that binary ports are not initialized until the (ice-9 binary-ports) module is loaded. As a result, the port returned by 'scm_open_bytevector_input_port' has a bad type tag. The workaround is to call scm_c_resolve_module ("ice-9 binary-ports") after initializing Guile before the first call to 'scm_open_bytevector_input_port'. The following code works: --8<---------------cut here---------------start------------->8--- #include int main() { scm_init_guile (); (void) scm_c_resolve_module ("ice-9 binary-ports"); SCM str = scm_c_make_bytevector (0); SCM port = scm_open_bytevector_input_port (str, SCM_UNDEFINED); scm_set_port_filename_x (port, scm_from_locale_string ("/usr/local/tmp/lilypond/ly/init.ly")); return 0; } --8<---------------cut here---------------end--------------->8--- Mark