From MAILER-DAEMON Fri Oct 10 14:08:10 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Xcebq-0006Po-Ha for mharc-bug-readline@gnu.org; Fri, 10 Oct 2014 14:08:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XccHc-0005yB-MP for bug-readline@gnu.org; Fri, 10 Oct 2014 11:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XccHV-0007Mu-0a for bug-readline@gnu.org; Fri, 10 Oct 2014 11:39:08 -0400 Received: from mailsrv.s3group.com ([193.120.90.35]:44545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XccHU-0007La-Lk for bug-readline@gnu.org; Fri, 10 Oct 2014 11:39:00 -0400 Received: from avsrvd.s3group.com (avsrvd.s3group.com [193.120.90.37]) by mailsrv.s3group.com with ESMTP id s9AFH2Gt016201 for ; Fri, 10 Oct 2014 16:17:03 +0100 Received: from avsrvd.s3group.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A563C15005D for ; Fri, 10 Oct 2014 16:17:02 +0100 (IST) Received: from excork2.dublin.ad.s3group.com (unknown [193.120.91.10]) by avsrvd.s3group.com (Postfix) with ESMTP id 94100150052 for ; Fri, 10 Oct 2014 16:17:02 +0100 (IST) Received: from [192.168.93.13] (192.168.93.13) by excork2.dublin.ad.s3group.com (193.120.91.10) with Microsoft SMTP Server (TLS) id 14.3.210.2; Fri, 10 Oct 2014 16:17:02 +0100 Message-ID: <5437F86F.3010607@s3group.com> Date: Fri, 10 Oct 2014 16:17:03 +0100 From: J Alan Brogan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.93.13] X-TM-AS-MML: No X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: avsrvd.s3group.com X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (mailsrv.s3group.com [193.120.90.35]); Fri, 10 Oct 2014 16:17:03 +0100 (IST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 193.120.90.35 X-Mailman-Approved-At: Fri, 10 Oct 2014 14:08:09 -0400 Subject: [Bug-readline] Readline starts vi editting mode in insert mode X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2014 15:39:15 -0000 Whereas vi and vim both start in "Normal" mode. I think that readline's vi mode should also start in "Normal" mode, and started asking on Stack Overflow: http://stackoverflow.com/questions/26277585/how-can-i-start-in-command-mode-not-insert-mode-in-readlines-vi-editting-mode OTOH: I can understand that starting in insert mode gives less of a learning curve to those unfamiliar with readline's vi editting mode, but would suggest that anyone who wants to turn on readline's vi editting mode is already expecting the "vim way of doing things" and would not be unduly perturbed to find themselves in the same (similar) mode as when vi starts. I cannot find any configuration settings to change that behaviour, but think I have the right place in to code: line 414 of readline.c (from current, 6.3, version of the code) where it has: #if defined (VI_MODE) if (rl_editing_mode == vi_mode) rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */ #endif /* VI_MODE */ My guess is that changing that call to rl_vi_insertion_mode() with rl_vi_movement_mode(), then readline will start in "Normal" mode. Line 180 of vi_mode.c, line 180: void rl_vi_start_inserting (key, repeat, sign) int key, repeat, sign; { _rl_vi_set_last (key, repeat, sign); rl_vi_insertion_mode (1, key); } My guess is that changing that similarly will put me into Normal mode after I hit return for a command. Any suggestions on what the key parameter into rl_vi_movement_mode() should be? 'i' is reasonable for insert mode, maybe '0' for movement mode? Any suggestions on how to hook in to the config system (I'd like to change the default for me, but assume others won't like it)? -- Alan Brogan ----- The information contained in this e-mail and in any attachments is confidential and is designated solely for the attention of the intended recipient(s). If you are not an intended recipient, you must not use, disclose, copy, distribute or retain this e-mail or any part thereof. If you have received this e-mail in error, please notify the sender by return e-mail and delete all copies of this e-mail from your computer system(s). Please direct any additional queries to: communications@s3group.com. Thank You. Silicon and Software Systems Limited (S3 Group). Registered in Ireland no. 378073. Registered Office: South County Business Park, Leopardstown, Dublin 18. From MAILER-DAEMON Mon Oct 13 09:14:25 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XdfSD-0002tC-H4 for mharc-bug-readline@gnu.org; Mon, 13 Oct 2014 09:14:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdfS6-0002l1-LL for bug-readline@gnu.org; Mon, 13 Oct 2014 09:14:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XdfS0-0005t5-MV for bug-readline@gnu.org; Mon, 13 Oct 2014 09:14:18 -0400 Received: from mpv2.tis.cwru.edu ([129.22.105.37]:7371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdfS0-0005su-Fl for bug-readline@gnu.org; Mon, 13 Oct 2014 09:14:12 -0400 Received: from mpv6.tis.CWRU.Edu (EHLO mpv6.cwru.edu) ([129.22.104.221]) by mpv2.tis.cwru.edu (MOS 4.3.5-GA FastPath queued) with ESMTP id BKG43776; Mon, 13 Oct 2014 09:14:11 -0400 (EDT) Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211]) by mpv6.cwru.edu (MOS 4.3.5-GA FastPath queued) with ESMTP id ARX54258 (AUTH cpr); Mon, 13 Oct 2014 09:14:01 -0400 (EDT) Message-ID: <543BD01F.4080805@case.edu> Date: Mon, 13 Oct 2014 09:14:07 -0400 From: Chet Ramey User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: J Alan Brogan , bug-readline@gnu.org References: <5437F86F.3010607@s3group.com> In-Reply-To: <5437F86F.3010607@s3group.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Junkmail-Status: score=10/50, host=mpv6.cwru.edu X-Junkmail-Whitelist: YES (by domain whitelist at mpv2.tis.cwru.edu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 129.22.105.37 Subject: Re: [Bug-readline] Readline starts vi editting mode in insert mode X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: chet.ramey@case.edu List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 13:14:24 -0000 On 10/10/14, 11:17 AM, J Alan Brogan wrote: > Whereas vi and vim both start in "Normal" mode. The most important thing is that readline exists so people can enter command lines. Users expect to be able to immediately enter a command at a shell prompt. I don't think that varying that much from user expectations is useful. If you want to start in command mode, you can always type ESC as the first thing. If you want to play around with it, you might start looking at rl_set_keymap_from_edit_mode() as well as the line in readline.c you identified, but this is not a candidate for inclusion in readline. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/ From MAILER-DAEMON Mon Oct 13 09:35:31 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Xdfmd-0006SG-CK for mharc-bug-readline@gnu.org; Mon, 13 Oct 2014 09:35:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdfmS-0006RI-L5 for bug-readline@gnu.org; Mon, 13 Oct 2014 09:35:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XdfmL-00059Q-Jj for bug-readline@gnu.org; Mon, 13 Oct 2014 09:35:20 -0400 Received: from mailsrv.s3group.com ([193.120.90.35]:59060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XdfmL-00059A-A9 for bug-readline@gnu.org; Mon, 13 Oct 2014 09:35:13 -0400 Received: from avsrvd.s3group.com (avsrvd.s3group.com [193.120.90.37]) by mailsrv.s3group.com with ESMTP id s9DDZ0Cr016529; Mon, 13 Oct 2014 14:35:00 +0100 Received: from avsrvd.s3group.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00B4615005D; Mon, 13 Oct 2014 14:35:00 +0100 (IST) Received: from excork2.dublin.ad.s3group.com (unknown [193.120.91.10]) by avsrvd.s3group.com (Postfix) with ESMTP id DCF88150052; Mon, 13 Oct 2014 14:34:59 +0100 (IST) Received: from [192.168.93.13] (192.168.93.13) by excork2.dublin.ad.s3group.com (193.120.91.10) with Microsoft SMTP Server (TLS) id 14.3.210.2; Mon, 13 Oct 2014 14:34:59 +0100 Message-ID: <543BD503.4030502@s3group.com> Date: Mon, 13 Oct 2014 14:34:59 +0100 From: J Alan Brogan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: , References: <5437F86F.3010607@s3group.com> <543BD01F.4080805@case.edu> In-Reply-To: <543BD01F.4080805@case.edu> Content-Type: text/plain; charset="windows-1252"; format="flowed" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.93.13] X-TM-AS-MML: No X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: avsrvd.s3group.com X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (mailsrv.s3group.com [193.120.90.35]); Mon, 13 Oct 2014 14:35:00 +0100 (IST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 193.120.90.35 Subject: Re: [Bug-readline] Readline starts vi editting mode in insert mode X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 13:35:28 -0000 Chet, Understand your reasoning perfectly. Thanks for the extra starting point. If I get anything working I'll put in on GitHub. -- Alan On 13/10/14 14:14, Chet Ramey wrote: > On 10/10/14, 11:17 AM, J Alan Brogan wrote: >> Whereas vi and vim both start in "Normal" mode. > The most important thing is that readline exists so people can enter > command lines. > > Users expect to be able to immediately enter a command at a shell prompt. > I don't think that varying that much from user expectations is useful. > If you want to start in command mode, you can always type ESC as the first > thing. > > If you want to play around with it, you might start looking at > rl_set_keymap_from_edit_mode() as well as the line in readline.c you > identified, but this is not a candidate for inclusion in readline. > > Chet > ----- The information contained in this e-mail and in any attachments is confidential and is designated solely for the attention of the intended recipient(s). If you are not an intended recipient, you must not use, disclose, copy, distribute or retain this e-mail or any part thereof. If you have received this e-mail in error, please notify the sender by return e-mail and delete all copies of this e-mail from your computer system(s). Please direct any additional queries to: communications@s3group.com. Thank You. Silicon and Software Systems Limited (S3 Group). Registered in Ireland no. 378073. Registered Office: South County Business Park, Leopardstown, Dublin 18. From MAILER-DAEMON Fri Oct 17 14:01:28 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XfBqB-0002Eu-Ud for mharc-bug-readline@gnu.org; Fri, 17 Oct 2014 14:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfBq3-0002Di-VJ for bug-readline@gnu.org; Fri, 17 Oct 2014 14:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfBpx-0003fz-O5 for bug-readline@gnu.org; Fri, 17 Oct 2014 14:01:19 -0400 Received: from rhcavspool01.kulnet.kuleuven.be ([134.58.240.193]:60746 helo=cavspool01.kulnet.kuleuven.be) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfBpx-0003fq-Iq for bug-readline@gnu.org; Fri, 17 Oct 2014 14:01:13 -0400 Received: from cavuit02.kulnet.kuleuven.be (rhcavuit02.kulnet.kuleuven.be [134.58.240.130]) by cavspool01.kulnet.kuleuven.be (Postfix) with ESMTP id 239AAAC5C for ; Fri, 17 Oct 2014 19:55:12 +0200 (CEST) X-KULeuven-Envelope-From: jo.vanbulck@student.kuleuven.be X-KULeuven-Scanned: Found to be clean X-KULeuven-ID: 57CA0128044.A4DB2 X-KULeuven-Information: Katholieke Universiteit Leuven Received: from icts-p-smtps-1.cc.kuleuven.be (icts-p-smtps-1e.kulnet.kuleuven.be [134.58.240.33]) by cavuit02.kulnet.kuleuven.be (Postfix) with ESMTP id 57CA0128044 for ; Fri, 17 Oct 2014 19:54:43 +0200 (CEST) Received: from ICTS-S-HUB2.luna.kuleuven.be (icts-s-hub2.luna.kuleuven.be [10.112.9.16]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by icts-p-smtps-1.cc.kuleuven.be (Postfix) with ESMTPS id 55CE94090 for ; Fri, 17 Oct 2014 19:54:43 +0200 (CEST) Received: from ICTS-S-MBX15.luna.kuleuven.be ([fe80::c955:6c9a:a5f3:b545]) by ICTS-S-HUB2.luna.kuleuven.be ([fe80::8559:ca7c:e195:e15d%26]) with mapi id 14.03.0195.001; Fri, 17 Oct 2014 19:54:42 +0200 X-Kuleuven: This mail passed the K.U.Leuven mailcluster From: Jo Van Bulck To: "bug-readline@gnu.org" Thread-Topic: segmentation fault in rl_parse_and_bind(char*) Thread-Index: Ac/qM23kaXn6m41tToK+HCAO0Tvqdg== Date: Fri, 17 Oct 2014 17:54:42 +0000 Message-ID: Accept-Language: nl-NL, nl-BE, en-US Content-Language: nl-NL X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.112.13.102] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 134.58.240.193 Subject: [Bug-readline] segmentation fault in rl_parse_and_bind(char*) X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2014 18:01:26 -0000 Hi all,=0A= =0A= When trying to parse a string as if it has been read from the inputrc=0A= file, using the 'rl_parse_and_bind(char *line)' function, I get a=0A= segmentation fault when passing any non-empy string. I run Archlinux=0A= with readline version 'readline 6.3.006-1'.=0A= =0A= The following C program is a minimal reproduction of the bug.=0A= =0A= /*=0A= * A modified readline example=0A= * (taken from=0A= http://cnswww.cns.cwru.edu/php/chet/readline/readline.html)=0A= * to demonstrate a bug in the rl_parse_and_bind(char*) function.=0A= *=0A= * compile with "gcc readline-bug-example.c -lreadline -o=0A= readline-bug-example"=0A= * rl version: readline 6.3.006-1=0A= */=0A= #include =0A= #include =0A= #include =0A= =0A= #define PARSE_STRING "set completion-ignore-case on"=0A= =0A= int main() {=0A= /* A static variable for holding the line. */=0A= static char *line_read =3D (char *) NULL;=0A= =0A= /* TODO the next line causes a segmentation fault for=0A= * any non-empty string;=0A= */=0A= rl_parse_and_bind(PARSE_STRING);=0A= =0A= while (line_read =3D readline("> ")) {=0A= printf("You entered '%s'\n", line_read);=0A= /* If the buffer has already been allocated,=0A= return the memory to the free pool. */=0A= if (line_read) {=0A= free (line_read);=0A= line_read =3D (char *) NULL;=0A= }=0A= }=0A= exit(0);=0A= }=0A= =0A= Executing the above program in gdb outputs: "Program received signal=0A= SIGSEGV, Segmentation fault.=0A= 0x00007ffff7bb3285 in rl_parse_and_bind () from /usr/lib/libreadline.so.6"= =0A= =0A= Any ideas on how to fix this?=0A= =0A= Regards=0A= =0A= From MAILER-DAEMON Fri Oct 17 14:57:54 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XfCio-0005CG-73 for mharc-bug-readline@gnu.org; Fri, 17 Oct 2014 14:57:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfCig-00059c-Px for bug-readline@gnu.org; Fri, 17 Oct 2014 14:57:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfCiY-0003Y5-4I for bug-readline@gnu.org; Fri, 17 Oct 2014 14:57:46 -0400 Received: from mpv1.tis.cwru.edu ([129.22.105.36]:42518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfCiX-0003WS-TC for bug-readline@gnu.org; Fri, 17 Oct 2014 14:57:38 -0400 Received: from mpv5.tis.CWRU.Edu (EHLO mpv5.cwru.edu) ([129.22.105.51]) by mpv1.tis.cwru.edu (MOS 4.3.5-GA FastPath queued) with ESMTP id BMT07728; Fri, 17 Oct 2014 14:57:36 -0400 (EDT) Received: from caleb.INS.CWRU.Edu (EHLO caleb.ins.cwru.edu) ([129.22.8.211]) by mpv5.cwru.edu (MOS 4.3.5-GA FastPath queued) with ESMTP id BCY53260 (AUTH cpr); Fri, 17 Oct 2014 14:57:36 -0400 (EDT) Message-ID: <544166A0.3020500@case.edu> Date: Fri, 17 Oct 2014 14:57:36 -0400 From: Chet Ramey User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Jo Van Bulck , "bug-readline@gnu.org" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Junkmail-Status: score=10/50, host=mpv5.cwru.edu X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 129.22.105.36 Subject: Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*) X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: chet.ramey@case.edu List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2014 18:57:52 -0000 On 10/17/14, 1:54 PM, Jo Van Bulck wrote: > Hi all, > > When trying to parse a string as if it has been read from the inputrc > file, using the 'rl_parse_and_bind(char *line)' function, I get a > segmentation fault when passing any non-empy string. I run Archlinux > with readline version 'readline 6.3.006-1'. It depends on the behavior of your compiler. rl_parse_and_bind wants to modify the string it's passed by temporarily putting in NULs and later restoring the original characters as part of tokenizing the line, similar to strtok/strsep. If your compiler puts string constants into read-only memory pages, you'll get a seg fault if you pass such a string constant to rl_parse_and_bind. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/ From MAILER-DAEMON Fri Oct 17 17:12:56 2014 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XfEpU-00089D-G9 for mharc-bug-readline@gnu.org; Fri, 17 Oct 2014 17:12:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfEpP-000892-53 for bug-readline@gnu.org; Fri, 17 Oct 2014 17:12:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XfEpJ-0003Jj-06 for bug-readline@gnu.org; Fri, 17 Oct 2014 17:12:51 -0400 Received: from rhcavuit02.kulnet.kuleuven.be ([2a02:2c40:0:c0::25:130]:51864 helo=cavuit02.kulnet.kuleuven.be) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XfEpI-0003Jb-PZ for bug-readline@gnu.org; Fri, 17 Oct 2014 17:12:44 -0400 X-KULeuven-Envelope-From: jo.vanbulck@student.kuleuven.be X-KULeuven-Scanned: Found to be clean X-KULeuven-ID: C3278128044.A3B7B X-KULeuven-Information: Katholieke Universiteit Leuven Received: from icts-p-smtps-2.cc.kuleuven.be (icts-p-smtps-2e.kulnet.kuleuven.be [134.58.240.34]) by cavuit02.kulnet.kuleuven.be (Postfix) with ESMTP id C3278128044; Fri, 17 Oct 2014 23:12:29 +0200 (CEST) Received: from ICTS-S-HUB2.luna.kuleuven.be (icts-s-hub2.luna.kuleuven.be [10.112.9.16]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by icts-p-smtps-2.cc.kuleuven.be (Postfix) with ESMTPS id C0A45200AC; Fri, 17 Oct 2014 23:12:26 +0200 (CEST) Received: from ICTS-S-MBX15.luna.kuleuven.be ([fe80::c955:6c9a:a5f3:b545]) by ICTS-S-HUB2.luna.kuleuven.be ([fe80::8559:ca7c:e195:e15d%26]) with mapi id 14.03.0195.001; Fri, 17 Oct 2014 23:12:26 +0200 X-Kuleuven: This mail passed the K.U.Leuven mailcluster From: Jo Van Bulck To: "chet.ramey@case.edu" , "bug-readline@gnu.org" Thread-Topic: [Bug-readline] segmentation fault in rl_parse_and_bind(char*) Thread-Index: Ac/qM23kaXn6m41tToK+HCAO0Tvqdv//8AsAgABHEL8= Date: Fri, 17 Oct 2014 21:12:25 +0000 Message-ID: References: , <544166A0.3020500@case.edu> In-Reply-To: <544166A0.3020500@case.edu> Accept-Language: nl-NL, nl-BE, en-US Content-Language: nl-NL X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.112.13.102] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:2c40:0:c0::25:130 Subject: Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*) X-BeenThere: bug-readline@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for GNU readline library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2014 21:12:55 -0000 Ok, I see now. Makes sense. Changing the example code to: char *a =3D malloc(strlen(PARSE_STRING)+1); strcpy(a,PARSE_STRING); rl_parse_and_bind(a); works indeed. Thanks for the quick reply :-) ________________________________________ Van: Chet Ramey [chet.ramey@case.edu] Verzonden: vrijdag 17 oktober 2014 20:57 Aan: Jo Van Bulck; bug-readline@gnu.org CC: chet.ramey@case.edu Onderwerp: Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*= ) On 10/17/14, 1:54 PM, Jo Van Bulck wrote: > Hi all, > > When trying to parse a string as if it has been read from the inputrc > file, using the 'rl_parse_and_bind(char *line)' function, I get a > segmentation fault when passing any non-empy string. I run Archlinux > with readline version 'readline 6.3.006-1'. It depends on the behavior of your compiler. rl_parse_and_bind wants to modify the string it's passed by temporarily putting in NULs and later restoring the original characters as part of tokenizing the line, similar to strtok/strsep. If your compiler puts string constants into read-only memory pages, you'll get a seg fault if you pass such a string constant to rl_parse_and_bind. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/=