Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiler error (trap). Stopping compilation.(DLL)

51 views
Skip to first unread message

Valentin KIELBASA

unread,
Nov 29, 2009, 4:10:40 PM11/29/09
to
Hello,

I would like to know if there is a limited number of functions in a Dynamic
Link Library (DLL) because LCC makes an error when I have about 30 functions

The error:

Compiler error (trap). Stopping compilation.

My exportable functions begin with the macro EXPORT which is defined as
#define EXPORT __declspec(dllexport) _stdcall

How can I make to have more than 30 functions ?

Thank you a lot.

Regards,

Valentin KIELBASA


jacob navia

unread,
Nov 30, 2009, 6:08:44 AM11/30/09
to
Valentin KIELBASA a �crit :

No, there are no limitations, and this error is produced by some
syntax in your file that makes the compiler trap...

Please send me the smalles piece of source code that reproduces this problem.


Trye to isolate it as much as you can, and then send me the source, I will
fix it ASAP.

jacob

Valentin KIELBASA

unread,
Nov 30, 2009, 8:06:02 AM11/30/09
to
Ok, thank you very much. I will give you a reproducible sample tomorrow.
I have the problem with two different projects.

Regards.

"jacob navia" <ja...@nospam.org> a �crit dans le message de news:
hf092p$k1s$1...@aioe.org...

Valentin KIELBASA

unread,
Dec 1, 2009, 12:26:28 PM12/1/09
to
Hello,

The attach source contains an example of the bug. The source is stand alone.
While making the source, I think that I have found why compiler bugs : the
bug appears when many functions name are a bit long.

My LCC version is : 4.0 (16 sep 2009 12:28:00)

Regards.


News group doesn't accept the attach piece.

I copy it here :

//BEGIN

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


#define EXPORT __declspec(dllexport) _stdcall

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_1(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_2(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_3(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_4(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_5(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_6(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_7(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_8(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_9(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_10(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_11(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_12(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_13(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_14(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_15(int a)
{
return a;
}


EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_16(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_17(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_18(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_19(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_20(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_21(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_22(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_23(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_24(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_25(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_26(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_27(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_28(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_29(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_30(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_31(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_32(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_33(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_34(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_35(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_36(int a)
{
return a;
}

EXPORT int PROCEDURE_WITHALONGTEXTASTHIS_37(int a)
{
return a;
}


// END


"jacob navia" <ja...@nospam.org> a �crit dans le message de news:
hf092p$k1s$1...@aioe.org...

jacob navia

unread,
Dec 2, 2009, 10:46:23 AM12/2/09
to
Valentin KIELBASA a �crit :
> Hello,
>
> The attach source contains an example of the bug. The source is stand alone.
> While making the source, I think that I have found why compiler bugs : the
> bug appears when many functions name are a bit long.
>

OK. Found the bug.

When the buffer for the function names to be exported is full (it defaults
to 1024 bytes) the compiler allocates a bigger buffer and copies the old contents
into the new bigger buffer with memcpy.

When the optimizer sees a memcpy call, however, it will try to replace
the memcpy by an inline function that does the same. It puts the length in
ecx, the uses the "loop" instruction to copy the bytes. All this without a
function call.

To avoid looping forever, you have to test if ecx is zero before doing the
loop instruction, to avoid wrapping it over to zero. To do this, the optimizer
will emit the jecxz instruction, that should test for ecx being zero.

And here (at last) is the bug: the internal assembler has problems assembling
the jecxz instruction apparently, and screws up the executable.

Since lcc is compiled with lcc, the generated compiler will crash.

I fixed the optimizer instead of fixing the assembler, and that is just a
quick fix... But it works. I will uploaded the version later this evening.

Valentin KIELBASA

unread,
Dec 3, 2009, 12:48:42 PM12/3/09
to
Ok, thank you very much Jacob, now it works!


"jacob navia" <ja...@nospam.org> a �crit dans le message de news:

hf623a$c6j$1...@aioe.org...

0 new messages