Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Wired memory limit error with autolink set #28

hooblei opened this Issue · 5 comments

2 participants



we have a custom render instance that extends Sundown\Render\Base. One of the overwritten methods (image()) throws an exception if something is wrong to prevent further processing - but if it does this, the script will die with a fatal error, while something is trying to allocate 4GB!

Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 4294967293 bytes) ...

Call Stack:
     2.0307   15032248  14. Sundown\Markdown->render() ...

This script should re-produce the error

#!/usr/bin/env php

class R extends \Sundown\Render\Base
    public function image($link, $title, $alt)
        if ($link == 'doesnt/exists.jpg') {
            throw new \Exception("err");

$c = <<<EOM
# Doc



$m = new \Sundown\Markdown(new R(), array('autolink' => true));

I've tested on two different systems, both with PHP 5.3.16 and php-sundown 0.4.0-beta + Sundown 1.15.2 - same result.

Now the wired - If I remove the autolink flag, or remove the second image link, or remove the schema from the second image url everything works as expected ... so I assume that's something related to autolink



I didin't expect throwing an exception on those methods. I'll fix soon.

@chobie chobie referenced this issue from a commit
@chobie WIP: #28 use setjmp 3b2ec2a

sundown does not have interrupt API. I guess it should should use setjmp.
I'll check this patch doesn't break PHP context. I need more time to fix this issue.


that would be great ... btw - in this case, we use the subclass of \Sundown\Render\Base actually not to render markdown content, it's just a handy way to grep all kind of makrdown links/url from a document and also do some kind of validation - so I thought interruption by an exception would be a valid case - especially as it worked out without the autolink flag set
anyway - if sundown was intended to do a render without interruption and a workaround is expensive or cumbersome, I'm totally fine with collecting the errors + checking for errors after render() is done and just fixing the docs

@chobie chobie closed this issue from a commit
@chobie * bumped up 0.3.8
- fixes #28 Wired memory limit error with autolink set.
Sundown\Render\Base callbacks are able to throw exceptions.
@chobie chobie closed this in 8bbfea0

@hooblei sorry for late response. I've just uploaded 0.3.8 release to PECL.


works - thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.