View previous topic :: View next topic |
Author |
Message |
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Mar 23, 2006 1:22 pm Post subject: Mango Logging |
|
|
Hi Eric;
I gather you've run into some issues with logging to the console? Can you relate what happens? I know there's an issue with the Win32 api, to do with passing very large buffers to it (> 32KB). Yet, that shouldn't be a problem since the time when Unicode support was added ...
- Kris |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Thu Mar 23, 2006 2:09 pm Post subject: |
|
|
Hey, here's what I know about the problem:
Code: | Not enough storage is available to process this command. |
This translates to system error #8 (ERROR_NOT_ENOUGH_MEMORY), as obtained by a call to getLastError()... somewhere.
Well I've done my best to narrow it down, and so far the effect is quite deterministic, but it only happens when I run the application in the command prompt. If I pipe the output directly to a file, this doesn't happen. (could windows be generating a larger set-aside buffer for output when a pipe is used, as opposed to the console window?)
This happens when I dump certain OMFBinary instances via toString() (specifically, one embedded within phobos.lib):
Code: | Stdout.println("binary: ?s",binary.toString); |
I know this ecause the 'binary: ' portion of the string manages to display, but is immediately followed by the error message (above). The program halts at that point.
Code: | binary: Error: Not enough storage is available to process this command. |
One last thing, my console is typically configured as follows: Code: | mode con: lines=999 cols=120 |
... I can't say if that's a variable here or not.
I'll let you know if I can come up with anything else. _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Mar 23, 2006 3:27 pm Post subject: |
|
|
Egad!
I'm looking at the code, and it's certainly possible to send more than 32K characters to WriteConsole at one time ~ I imagine that's the problem, having seem a similar thing about a year ago.
The redirect operates correctly because it sidesteps WriteConsole, and does a WriteFile instead.
I'll get a patch out to you soon;
- Kris |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Thu Mar 23, 2006 4:12 pm Post subject: |
|
|
I just checked-in a change to mango.io.Console, which should manage the amount of data sent to WriteConsole (on line 297). Haven't tried it yet, but I think it should be OK. If you get the same error, try changing the 32767 to something smaller (like 16384)
The concern I have with this 'fix' is the potential for splitting a UTF16 surrogate-pair; chunking the output in a simplistic manner may not work for all cases, yet it's a royal pain to start checking all that when the overwhelming majority of cases won't trip. Still, the WriteConsole function sucks for tossing an error instead of clipping and returning what it could emit instead (which it already does in general).
edit: just added a check for surrogate-pairs too |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
pragma
Joined: 28 May 2004 Posts: 607 Location: Washington, DC
|
Posted: Fri Mar 24, 2006 8:26 am Post subject: |
|
|
Kris, thanks for the assist. On my next pass, I'll be adding these improvements in. Hopefully, this will stomp out the bug. ![Smile](images/smiles/icon_smile.gif) _________________ -- !Eric.t.Anderton at gmail |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|