[
https://issues.apache.org/jira/browse/CLOWNFISH-44?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14546886#comment-14546886
]
Nick Wellnhofer commented on CLOWNFISH-44:
------------------------------------------
Another note: If we copied string SVs before passing them as arguments, we
wouldn't need the clone-on-incref hack. This means that we'd never have to copy
string buffers under a COW-enabled Perl.
On the other hand, we also rely on clone-on-incref behavior to ensure thread
safety.
> Immutable Strings can be changed from Perl
> ------------------------------------------
>
> Key: CLOWNFISH-44
> URL: https://issues.apache.org/jira/browse/CLOWNFISH-44
> Project: Apache Lucy-Clownfish
> Issue Type: Bug
> Components: Perl
> Reporter: Nick Wellnhofer
> Priority: Minor
>
> Perl can hold a reference to a string passed to Clownfish and subsequently
> change the string via this reference in a callback. This violates the
> assumption that Clownfish strings are immutable and can lead to crashes if
> the string buffer is reallocated.
> This scenario is somewhat contrived but for a proper fix, I think there's no
> other way than to always copy Perl strings passed as arguments. Fortunately,
> newer Perls support copy-on-write strings (default since 5.20) which makes
> this operation cheap.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)