{"id":73,"date":"2006-02-19T14:21:32","date_gmt":"2006-02-19T13:21:32","guid":{"rendered":"http:\/\/web.glandium.org\/blog\/?p=73"},"modified":"2010-01-27T08:52:40","modified_gmt":"2010-01-27T07:52:40","slug":"is-libpng-crap-and-php","status":"publish","type":"post","link":"https:\/\/glandium.org\/blog\/?p=73","title":{"rendered":"Is libpng crap ? and php ?"},"content":{"rendered":"<p>As <a href=\"\/blog\/?p=72\">I told before<\/a>, I've been working for a few days on a way to display japanese characters on a web page when you don't have japanese fonts locally. That involved taking japanese characters from a font file, and turning it into a png image. So I just wrote a small and simple program using libpng and freetype. Which works quite well. But that's not the point.<\/p>\n<p>During this \"development\", I lost 2 or 3 days trying to understand what was wrong with my code that made it work properly from a shell command and fail halfway when wrapped in a php script. I still don't know what's wrong with php, but it works well with a perl cgi wrapper, and it still fails if I raise the php memory limit. Interestingly, other libpng tools (such as pngtopnm) fail in the same way. It wouldn't surprise me if it was libpng's fault.<\/p>\n<p>The first thing i did to understand why it'd fail, was to run the program under valgrind. And what I saw was not encouraging. A lot of \"Conditional jump or move depends on uninitialised value(s)\". I tried different combinations of code, using png_write_image or png_write_row, with large or small buffers... <\/p>\n<p>It turns out libpng can't write a png file with a width smaller than 148 pixels without those \"Conditional jump or move depends on uninitialised value(s)\", which happen, as the stack trace shows, in the zlib, called by png_write_row, but i doubt it to be a zlib issue. You would think it would be a buffer size issue, but if you use a larger buffer for each line you call png_write_row for, you still get the errors.<\/p>\n<p>If anyone has a clue, please leave a comment.<\/p>\n<p><b>Update<\/b>: Thanks <a href=\"http:\/\/www.sirena.org.uk\/log\/?p=26\">Mark<\/a> for your comment, though I don't get how it can be safe to have such accesses to uninitialized memory. Deuce, the php issue can't be a timeout issue, the program runs in fractions of a second.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I told before, I&#8217;ve been working for a few days on a way to display japanese characters on a web page when you don&#8217;t have japanese fonts locally. That involved taking japanese characters from a font file, and turning it into a png image. So I just wrote a small and simple program using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,5],"tags":[23],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-misc","category-pdo","tag-en"],"_links":{"self":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":1,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":778,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/778"}],"wp:attachment":[{"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/glandium.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}