-
Notifications
You must be signed in to change notification settings - Fork 553
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
Say "Perl: Out of memory", not just "Out of memory" #21672
Comments
|
The example at https://perlm aven.com/out-o f-memory shows a user knowingly running a perl script that consumes more memory than the system has. What, if not perl, would be in a position to print that error to their terminal? |
|
The main reason, why there is so much confusion as to what is printing that message, is that perl's messages always always always always always have some line number mentioned in them. Yes, they might not say which item on a certain line caused the problem, but at least they have a line number and the name of some file attached to them. So if perl would be kind enough to print that also, instead of just throwing up its hands and sayimg "out of memory" , then it would save a tons of confusion for all the people trying to hunt problems down. That way people would not assume that this could not possibly be perl printing the message, so must be something else, so the only other thing would be the owner of the memory, which is the kernel. |
|
And Googling for "Perl out of memory" shows many people not only not clear who is printing the message, but also desperately trying to find which part of their program is making the error. So adding a line number would help enormously. Certainly perl has some up its sleeves that it could print while printing the Out of memory message. You might say that being so chatty might make perl's look like python's messages. Well yes. |
|
I mean, even messages from the telephone company, have "message number 374-M" added to them at least. That way when people call customer service they can refer to the message number. That's why this particular message seems so unlike perls'. It seems sort of like some spam message injected trying to get people to click on something. Out of diis space. Click here to buy some more. Out of memory. Click here to buy some more. "Your system is not optimized." Etc. Yes, there is "no click here to buy some more" attached this message, but still.. it looks very suspicious. Not like any other message perl has ever made. I mean usually perl is not in such a panic that it can't remember at least one line number. Okay. In this case there may be good reasons for not knowing the line number, but at least it should know it's own name, perl, and print that too. |
The error number in this case is "out of memory", and you did quote that when you contacted customer service.
The actual question is "What? Why did the x operator consume all the memory?" The answer is in perlsecpolicy:
It sounds nice to say "give me a line number", but which line number? Every single variable in the program occupies memory. Files and sockets are buffered, regex captures come and go, and the interpreter even keeps some for itself, just as a little treat. If your program is any more complicated than One of the PM articles in this search result also mentions that the message is short because strings take up memory, and there might not be enough of that around to fit a longer error message into. (that might be less true on modern hardware though) |
The problem: When perl runs out of memory, it outputs a generic "Out of
memory!" error and exits. This makes it hard to track down what's
happening in a complex system, especially since the message does not
even mention perl.
This patch contains two main changes:
1. vec() in lvalue context can throw fake "Out of memory!" errors when
it discovers that the index being assigned to is too big. Unlike real
allocation errors, these are trappable with try {}/eval {}.
This message has been changed to "Out of memory during vec in lvalue
context" (and since it comes from a Perl_croak() call, it will
generally have a script name and line number attached).
2. All other places in the source code that can emit "Out of memory!"
errors have been changed to attach a location identifier to the
message. For example: "Out of memory in perl:util:safesysmalloc"
This way the error message at least mentions "perl".
Fixes Perl#21672.
|
It's just like "out of money." I'm not concerned why I ran out of money, yet. First I would just like to answer the question: Who says I'm out of money? Was it my bank, my dentist, my credit union, my sports club, the IRS...? Anyway I'm glad to see the 75 changes have been made due to my bug report. Thank you everybody. |
The problem: When perl runs out of memory, it outputs a generic "Out of
memory!" error and exits. This makes it hard to track down what's
happening in a complex system, especially since the message does not
even mention perl.
This patch contains two main changes:
1. vec() in lvalue context can throw fake "Out of memory!" errors when
it discovers that the index being assigned to is too big. Unlike real
allocation errors, these are trappable with try {}/eval {}.
This message has been changed to "Out of memory during vec in lvalue
context" (and since it comes from a Perl_croak() call, it will
generally have a script name and line number attached).
2. All other places in the source code that can emit "Out of memory!"
errors have been changed to attach a location identifier to the
message. For example: "Out of memory in perl:util:safesysmalloc"
This way the error message at least mentions "perl".
Fixes #21672.
Please have perl print
not just
Else it is hard to tell what printed that message.
szabgab/perlmaven.com#583
Yes, I know perl doesn't like to say "Perl: " before its
messages. But it would be nice if it was like bash, and did.
The text was updated successfully, but these errors were encountered: