You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucy.apache.org by "Marvin Humphrey (JIRA)" <ji...@apache.org> on 2015/11/04 03:23:27 UTC

[lucy-issues] [jira] [Commented] (CLOWNFISH-62) Crash when passing Perl variable as decremented arg

    [ https://issues.apache.org/jira/browse/CLOWNFISH-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14988758#comment-14988758 ] 

Marvin Humphrey commented on CLOWNFISH-62:
------------------------------------------

I agree that forgoing the stack string optimization is a good stratagem here.

This is really a bug, though.  When passing a `decremented` argument, the caller is responsible for creating and then handing off a refcount. Wrapping a stack string around the buffer content of a Perl string SV is a refcount-neutral operation, and thus it's the wrong thing to do when preparing a `decremented` arg. If we know that we have only a Perl SV yet we need a decremented arg, the expectation should be that we create a full-blown Clownfish String.

> Crash when passing Perl variable as decremented arg
> ---------------------------------------------------
>
>                 Key: CLOWNFISH-62
>                 URL: https://issues.apache.org/jira/browse/CLOWNFISH-62
>             Project: Apache Lucy-Clownfish
>          Issue Type: Bug
>          Components: Perl
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Nick Wellnhofer
>
> Passing a Perl variable to a method that takes a "decremented" argument results in a use-after-free. Example
> {noformat}
> perl -MClownfish -e 'Clownfish::Vector->new->push("abc")'
> {noformat}
> Analysis:
> - A Clownfish "stack" string is created from the string value of the Perl variable.
> - The stack string is passed to Vec_Push.
> - The stack string is never incref'd.
> - The copy-on-incref mechanism isn't invoked.
> - When the Vector is destroyed, the stack string is decref'd, accessing random stack memory.
> A possible solution is to forgo the stack string optimization for decremented arguments.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)