New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached. #19160

Closed
novawish opened this Issue Aug 30, 2017 · 34 comments

Comments

Projects
None yet
@novawish
Copy link
Contributor

novawish commented Aug 30, 2017

Impacted versions:
Odoo 10, wkhtmltopdf 0.12.4

Steps to reproduce:
Print a PDF report with a field Text placed at the bottom of the page. The size of field Text must be long enough to overflow the current page so it must creates a new page

Current behavior: Show errors:
Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached.

Expected behavior:
The content of field Text must split to a new page or move completely to a new page

@Yenthe666

This comment has been minimized.

Copy link
Contributor

Yenthe666 commented Sep 1, 2017

Hi @novawish,

Thank you for your report.
It is however not advised to use wkhtmltopdf version 0.12.2.x, 0.12.3.x or 0.12.4.x as stated in the wiki at: https://github.com/odoo/odoo/wiki/Wkhtmltopdf
Please downgrade your wkhtmltopdf to 0.12.1.x and you'll most likely won't face this issue anymore.
Can you please downgrade and let us know if everything is working fine?

Regards,
Yenthe

@novawish

This comment has been minimized.

Copy link
Contributor

novawish commented Sep 1, 2017

Hi @Yenthe666,

Thanks for your reply.
I have downgraded the wkhtmltopdf to 0.12.1.x and it's fine to print. However, the headers are overlapped with the contents of the body.
I found the workaround way for this issue (with wkhtmltopdf 0.12.4.x), though it sounds irrelevant but worked: In my case, I set the style="min-height: 300px" for the Text field at the bottom of page so that it can be split to the new page.

If anyone had the same issue, you may try that solution and give me feedback

Regards,

@mkschreder

This comment has been minimized.

Copy link

mkschreder commented Nov 2, 2017

I have downgraded to v0.12.1 and I'm still having the same problem. Wouldn't it be better if odoo bundled the right version with the release? Seems ridiculous to me that we have to manually compile a custom version of qt in order to use odoo.

@jl2035

This comment has been minimized.

Copy link
Contributor

jl2035 commented Nov 6, 2017

@mkschreder It's ridiculous, I agree.

I'm also haviing this issue. Downgrading to 0.12.1 does not solve the problem.

@mkschreder

This comment has been minimized.

Copy link

mkschreder commented Nov 7, 2017

Go this now and printing works:
Name:
wkhtmltopdf 0.12.1 (with patched qt)
I believe it was this guide that solved it: https://stackoverflow.com/questions/34479040/how-to-install-wkhtmltopdf-with-patched-qt However in the end I had so many versions on my system I don't know which one ended up working.

@aliencrash

This comment has been minimized.

Copy link

aliencrash commented Nov 8, 2017

Having the same issue here, cannot print any document.

@novawish

This comment has been minimized.

Copy link
Contributor

novawish commented Nov 8, 2017

@mkschreder @jl2035 @aliencrash Did you try the solution I mentioned above?

@jl2035

This comment has been minimized.

Copy link
Contributor

jl2035 commented Nov 8, 2017

@novawish yes, but I can't print invoices.

me@vps134323:~$ wkhtmltopdf --version
wkhtmltopdf 0.12.1 (with patched qt)

@mkschreder

This comment has been minimized.

Copy link

mkschreder commented Nov 8, 2017

For me just downgrading did not work. I had to have a special version built with modified qt.

@jl2035

This comment has been minimized.

Copy link
Contributor

jl2035 commented Dec 11, 2017

I ended up here again. This is one of the biggest nightmares in Odoo!

@rim-odoo

This comment has been minimized.

Copy link
Contributor

rim-odoo commented Jan 8, 2018

The CSS of the report causes wkhtmltopdf to eat too much RAM. Either you can upsize your memory limit (if your server can handle it), either you must change the text at the bottom of the page in order to change a bit the number of pages. This issue is very nasty since wkhtmltopdf crashes without indicating the real source of the problem that seems to be the evaluation of some CSS rule

opw-804203

@aliencrash

This comment has been minimized.

Copy link

aliencrash commented Jan 8, 2018

The actual problem is with openssl library, verify with version you are using and install openssl 1.0. This is an issue with QT

@chris001

This comment has been minimized.

Copy link

chris001 commented Jan 11, 2018

@aliencrash

  1. Can you provide a link to the problem issue with openssl library in the fork of QT embedded inside wkhtmltopdf.
  2. Are you using this setting from #5177 for web.base.url ?
    @DarkoNikolovski @steenzout @sle-odoo @aab-odoo
    https://github.com/wkhtmltopdf/wkhtmltopdf/releases/
    0.12.1 is 3.5 years old, and contains hundreds of security issues and bugs.
    0.12.4 is the current stable, is 1.25 years old, and has fixed hundreds of bugs and security issues since 0.12.1.
    Can you confirm wkhtmltopdf version 0.12.4 is working fine on Odoo 11, as long as web.base.url value is set to http://127.0.0.1:8069 ??
@aliencrash

This comment has been minimized.

Copy link

aliencrash commented Jan 15, 2018

@chris001

  1. This is the error wkhtmltopdf/wkhtmltopdf#3001.
  2. I'm not using any settings. If you type wkhtmltopdf www.google.com google.pdf on your console you will get the error even with version 0.12.4. So it's not actually related to Odoo.
@chris001

This comment has been minimized.

Copy link

chris001 commented Jan 15, 2018

@aliencrash
I just tested this exact command on ubuntu 16.04 while logged in as root (not that it should matter which user you're running it as) and it worked.
Which OS you using?
Which version wkhtmltopdf?
Downloaded wkhtmltopdf from which link?

root@server7:~# wkhtmltopdf www.google.com google.pdf
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
root@server7:~# ls -la *.pdf
-rw-r--r-- 1 root root 100100 Jan 15 11:21 google.pdf
root@server7:~# wkhtmltopdf --version
wkhtmltopdf 0.12.4 (with patched qt)
@aliencrash

This comment has been minimized.

Copy link

aliencrash commented Jan 15, 2018

I upgraded again the openssl-devel library to version 1.1
I'm using fedora 27.

wkhtmltopdf 0.12.4 (with patched qt)

wkhtmltopdf www.google.com google.pt
Loading pages (1/6)
QSslSocket: cannot resolve CRYPTO_num_locks ] 10%
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num
QSslSocket: cannot resolve sk_pop_free
QSslSocket: cannot resolve sk_value
QSslSocket: cannot resolve SSL_library_init
QSslSocket: cannot resolve SSL_load_error_strings
QSslSocket: cannot resolve SSLv23_client_method
QSslSocket: cannot resolve SSLv23_server_method
QSslSocket: cannot resolve X509_STORE_CTX_get_chain
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
QSslSocket: cannot resolve SSLeay
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function sk_num
Segmentation fault (core dumped)

@chris001

This comment has been minimized.

Copy link

chris001 commented Jan 15, 2018

@aliencrash
Gathered from wkhtmltopdf/wkhtmltopdf#3001
It appears this is the fix for fedora, because QT inside wkhtmltopdf requires ssl 1.0 :

Fedora 26 breaks it, you need the 1.1.0 ssl devel libs. This solves it:

dnf install compat-openssl10-devel.x86_64 --allowerasing
The new version of QT, 5.10, which will be added to the new version of wkhtmltopdf soon, should run without crashing on popular versions of openssl.

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented Apr 30, 2018

Not sure if this can help the debate, but it just happened to us today too.
I have run the ubuntu command wkhtmltopdf www.google.com google.pdf

Loading pages (1/6)
Fontconfig warning: ignoring UTF-8: not a valid region tag ] 10%
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

Till now it was working like a charm we could print all documents from our Odoo 11.

And even though the test proves it works, I still get the following message :

Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached. Message : b''

Our version wkhtmltopdf 0.12.4 (with patched qt)

I have checked also the memory limit in config file. I have read somewhere it could be related. Not sure though.
We installed our Odoo 11 with @chris001 's patch so the config file is quite complete and I don't think it would come from this.
I have read there is an upgrade coming of wkhtmltopdf. Would this solve the case?

@chris001

This comment has been minimized.

Copy link

chris001 commented Apr 30, 2018

@FlyingPigSolutions
This should solve your issue:
wkhtmltopdf/wkhtmltopdf#2592

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

I tried to increase memory from what it was:

limit_memory_hard = 2684354560
limit_memory_soft = 2147483648

TO

limit_memory_hard = 4684354560
limit_memory_soft = 4147483648

then restarted the odoo server : sudo service odoo-server restart

Problem remain the same :

Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached. Message : b''

We have in our ubuntu server this configuration :

2 GB Memory / 30 GB Disk / 1vCPU

Could it be really just a RAM issue on the server? I think 2GB is more than enough. There is nothing else shared on that server. What you think?

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

Checking the link your mentioned @chris001, I also checked on terminal with command ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7928
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7928
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

then increased the open files with ulimit -n 10000

now I have raised the open files limit :

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7928
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 10000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7928
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

Still got the message error:

Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached. Message : b''

That's tricky… Would raising the RAM of the server do the trick? I wonder...

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

Ok raising the server RAM from 2GB to 4GB did not solved it. Unless I missed something like restarting the Ubuntu or something? Did anyone solved this issue unlimiting the open files?

After restarting the ubuntu server:

BTW Shutting down the server and restarting it did not change a thing.

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

Ok, making further test, it seems I can print sales proforma, order quotation, order.
What I can't print is, after sales confirmation, the delivery slip.
I can print preparation order document though (the one with barcode).
And I can print Invoices.

My test was done with the same order.
So the only document I can't print from the whole order process is the delivery slip.

Total mystery...

@aliencrash

This comment has been minimized.

Copy link

aliencrash commented May 2, 2018

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

Thanks @aliencrash I'll try that.
It's surprising coz it just happened to not work when it was working fine till now:

To check version, type the following command in your terminal:

openssl version -a

OpenSSL 1.0.2g 1 Mar 2016

apt-cache policy openssl

openssl:
Installed: 1.0.2g-1ubuntu4.12
Candidate: 1.0.2g-1ubuntu4.12
Version table:
*** 1.0.2g-1ubuntu4.12 500

@FlyingPigSolutions

This comment has been minimized.

Copy link

FlyingPigSolutions commented May 2, 2018

I have run sudo apt-get install openssl

Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version (1.0.2g-1ubuntu4.12).
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-104 linux-headers-4.4.0-104-generic linux-headers-4.4.0-109
linux-headers-4.4.0-109-generic linux-headers-4.4.0-112 linux-headers-4.4.0-112-generic
linux-image-4.4.0-104-generic linux-image-4.4.0-109-generic linux-image-4.4.0-112-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.

Now it is working. o_0 Problem seems to be solved. For now... [TO BE CONTINUED]

Thank you @aliencrash @chris001

@Yenthe666

This comment has been minimized.

Copy link
Contributor

Yenthe666 commented May 3, 2018

@novawish are you still facing this issue? Can you try the provided solution for the openssl package too please?

@Yenthe666

This comment has been minimized.

Copy link
Contributor

Yenthe666 commented May 22, 2018

Hi there,

I'm closing this bug report as there has been no feedback in a few weeks from the author and as some fixes have been provided.

Regards,
Yenthe

@Yenthe666 Yenthe666 closed this May 22, 2018

@Auneor

This comment has been minimized.

Copy link

Auneor commented May 28, 2018

Hi @Yenthe666 ,
I'm experiencing the same issue. I've tried all fixes suggested here
and nothing make it works
It's odoo10 enterprise
For a certain report and a certain object, it's working fine, until
adding 4 cells in a table of the template (with nothing in it) the
error appears
I've set a very high ulimit, I have 16Gb of ram, and I've set the odoo
memory limits very hight
Ubuntu 16.04
simon@ ~ () $ wkhtmltopdf --version
wkhtmltopdf 0.12.1 (with patched qt)
ii openssl 1.0.2g-1ubuntu4.12 amd64 Secure Sockets Layer toolkit - cryptographic utility

Regards

@idealisconsultingbe

This comment has been minimized.

Copy link

idealisconsultingbe commented May 30, 2018

Hi,
Same problem for me.
I find a way to print the document by adding --disable-smart-shrinking to the command with a batch script, but the PDF isn't the same anymore.

Here is what I did:

mv /usr/local/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf_original
touch /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
nano /usr/local/bin/wkhtmltopdf

and add the following lines:

#!/bin/bash
wkhtmltopdf_original --disable-smart-shrinking $@

But this is not a real solution as the design isn't the same anymore...

Regards

@Yenthe666 Yenthe666 reopened this May 30, 2018

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented May 30, 2018

This is not an Odoo problem, but wkhtmltopdf one, and we provided a reproducible case 2 weeks ago to the developer for fixing it (wkhtmltopdf/wkhtmltopdf#2711 (comment)), and he has said that is going to be fixed on next release, but nothing to do on Odoo side.

@mart-e the upgrade to the new version is going to be mandatory if we want a good behavior.

Closing this issue by the reasons above.

@eLBati

This comment has been minimized.

Copy link
Contributor

eLBati commented Sep 19, 2018

@pedrobaeza @mart-e odoo could allow user to increase the maximum number of open file descriptors and avoid this error (with Wkhtmltopdf 0.12.1 also), with an additional option --limit-open-files
See #27115

@pedrobaeza

This comment has been minimized.

Copy link
Contributor

pedrobaeza commented Sep 19, 2018

@eLBati it's not the same problem. For solving this one, upgrade to 0.12.5. Description is above.

@bunhin

This comment has been minimized.

Copy link

bunhin commented Sep 27, 2018

I have similar error message when try to print General Ledger Report with data range more than 2 month with all journals, is it the same problem with wkhtmltopdf?, i am using v 0.12.4 on centos 7. Can print OK if only 1 or 2 months period

here is the error message :
"Wkhtmltopdf failed (error code: -11). Memory limit too low or maximum file number of subprocess reached. Message : tepages=1273&webpage=/tmp/report.body.tmp.KWFeYl.html&time=12:37 PM&date=9/27/18 (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed loading page file:///tmp/report.header.tmp.qULVx5.html?page=1272&section=PT...........: General ledger&sitepage=1272&title=&subsection=&frompage=1&subsubsection=&isodate=2018-09-27&topage=1273&doctitle=&sitepages=1273&webpage=/tmp/report.body.tmp.KWFeYl.html&time=12:37 PM&date=9/27/18 (sometimes it will work just to ignore this error with --load-error-handling ignore)
Error: Failed loading page file:///tmp/report.header.tmp.qULVx5.html?page=1273&section=PT...........: General ledger&sitepage=1273&title=&subsection=&frompage=1&subsubsection=&isodate=2018-09-27&topage=1273&doctitle=&sitepages=1273&webpage=/tmp/report.body.tmp.KWFeYl.html&time=12:37 PM&date=9/27/18 (sometimes it will work just to ignore this error with --load-error-handling ignore)
QPaintDevice: Cannot destroy paint device that is being painted"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment