Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- From: "Trevor Short" <trevors@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Apr 2005 07:57:19 -0700
>> When the above line of code is called on a pointer to memory without a
>> null terminator it will read past what you might consider to be the end
>> of
>> the string into random memory until it finds one.
>
> That is not happening in VB6. In Japanese VB6, the generated EXE always
> corrupts the ANSI string but still always appends a null char. In US VB6,
> in 25% of cases (depending on the string length but 100% reproducible in
> those cases) the generated EXE corrupts the ANSI string. But VB6 still
> always appends a null char, MSDN and several famous books describe that
> correctly.
>
Is there any way for you to provide a repro for the Japanese VB6 case? I
am not seeing any corruption on my part (I'm on US VB6) and so I don't think
I'm hitting the 25% case. If it is happening 100% of the time with Japanese
VB6 I wouldn't mind taking a look there instead.
> Aside: VB2003 sometimes screws it up in the way you say, not putting in a
> null char if the number of bytes in the ANSI version exactly holds the
> converted contents of the string.
>
>> It's possible that your customer's program might be making the same
>> assumption. This may result in crashes and other seemingly odd behavior.
>
> The customer's program doesn't do that. I wrote a few experiments in
> order
> to find out what was happening, and found corruption in the strings. As
> part of my experiments I found out where the null char is but the
> customer's
> program didn't depend on the null char that way.
Is the customers program using fixed-length strings or variable-length
strings? I am seeing differences between the two in terms of whether a null
character is put in at the end after going to the C dll. The fixed-length
string is not. The variable-length strings are. The fixed-length strings
are being filled up with space characters. Chr(0x20)
BTW, I saw on the the other thread on this topic that you may in fact
have found the problem and possibly the solution. I would recommend that
you upgrade to VB6 SP4 and see if that fixes the problem that you are
seeing. Have you been able to do that and how did that go? In addition,
the most recent version of VB6 is SP6 and I don't know if you would be
interested in upgrading to SP6 or not?
Trevor Short
Microsoft Visual Basic Development.
.
- Follow-Ups:
- Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- From: Norman Diamond
- Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- References:
- Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- From: Trevor Short
- Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- From: Norman Diamond
- Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- Prev by Date: Re: XP Service Pack 2 VB6 Speed deteriorates
- Next by Date: VB6 form Screen width
- Previous by thread: Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- Next by thread: Re: VB6 generates faulty exe code: UDT passed from VB6 to DLL
- Index(es):
Relevant Pages
|