tounicode.w: Stack overflow on Windows 7 (and one possible fix)
Hi All I just completed "porting" LuaTeX to a native Windows build (Windows 7 Ultimate 64-bit) using Visual Studio. I hit a stack overflow error when entering the following function: // #line 456 "tounicode.w" int write_cid_tounicode(PDF pdf,fo_entry*fo,internal_font_number f) { int range_size[65537]; glyph_unicode_entry gtab[65537]; ...... Using the guidelines/advice here: http://www.onlamp.com/pub/a/onlamp/2005/11/23/memory-management-2.html I changed the above code to: int write_cid_tounicode(PDF pdf,fo_entry*fo,internal_font_number f) { static int range_size[65537]; static glyph _unicode_entry gtab[65537]; And, for sure, no more stack overflows and it now works fine. Not sure if it's the best fix, but for now it seems to work. Best Graham
Hello. It's good if there is no need for multithreading or recursion. More elegant solution would be something like that: int *range_size = malloc(65537 * sizeof(int)); assert(range_size); glyph_unicode_entry *gtab = malloc(65537 * sizeof(glyph_unicode_entry)); assert(gtab); <...> free(gtab); free(range_size); Regards, Mindaugas. On 2013-09-03 01:30, Graham Douglas wrote:
static int range_size[65537]; static glyph _unicode_entry gtab[65537];
Hi Sure, I agree, dynamically allocating the arrays would probably be preferable. Best Graham
Have you tried to enlarge the default stack size ?
It should solve the problem.
However, if the arrays can be static, then it is much more efficient.
Fabrice
2013/9/3 Graham Douglas
Hi
Sure, I agree, dynamically allocating the arrays would probably be preferable.
Best Graham _______________________________________________ dev-luatex mailing list dev-luatex@ntg.nl http://www.ntg.nl/mailman/listinfo/dev-luatex
-- Fabrice Popineau ----------------------------- SUPELEC Département Informatique 3, rue Joliot Curie 91192 Gif/Yvette Cedex Tel direct : +33 (0) 169851950 Standard : +33 (0) 169851212 ------------------------------
On 03/09/2013 07:01, Fabrice Popineau wrote:
Have you tried to enlarge the default stack size ? It should solve the problem. However, if the arrays can be static, then it is much more efficient.
Fabrice
Hello Fabrice Yes, I increased the default stack size this morning and it does also solve the problem. The default was 1MB, I think. Warm wishes Graham
On Tue, Sep 3, 2013 at 8:33 AM, Graham Douglas < graham.douglas@readytext.co.uk> wrote:
On 03/09/2013 07:01, Fabrice Popineau wrote:
Have you tried to enlarge the default stack size ? It should solve the problem. However, if the arrays can be static, then it is much more efficient.
Fabrice
Hello Fabrice
Yes, I increased the default stack size this morning and it does also solve the problem. The default was 1MB, I think.
I have seen a linker option /STACK:0x280000 in my old copy of the sources from http://w32tex.org/ -- luigi
On 09/03/2013 08:01 AM, Fabrice Popineau wrote:
Have you tried to enlarge the default stack size ? It should solve the problem. However, if the arrays can be static, then it is much more efficient.
Switched to static (rev 4642) Best wishes, Taco
participants (5)
-
Fabrice Popineau
-
Graham Douglas
-
luigi scarso
-
Mindaugas Piešina
-
Taco Hoekwater