bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*)


From: Jo Van Bulck
Subject: Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*)
Date: Fri, 17 Oct 2014 21:12:25 +0000

Ok, I see now. Makes sense. Changing the example code to:

    char *a = malloc(strlen(PARSE_STRING)+1);
    strcpy(a,PARSE_STRING);
    rl_parse_and_bind(a);

works indeed. Thanks for the quick reply :-)
________________________________________
Van: Chet Ramey address@hidden
Verzonden: vrijdag 17 oktober 2014 20:57
Aan: Jo Van Bulck; address@hidden
CC: address@hidden
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    address@hidden    http://cnswww.cns.cwru.edu/~chet/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]