|
-
September 14th, 2010, 10:07 AM
#1
Error in str_misaligned in application in Windows 7
Hello!
I have developed a big application on Windows XP. Now I changed my OS to Windows 7 with a new computer.
I just copied the whole project and the settings of my Visual Studio 2005, and the compiling went well. But starting the application, I get an error
Unhandled exception at 0x5e8bb10c (msvcr80d.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0x000000fe
File strlen.asm:
Code:
str_misaligned:
; simple byte loop until string is aligned
mov al,byte ptr [ecx] <- Error
add ecx,1
test al,al
je short byte_3
test ecx,3
jne short str_misaligned
while just concate 2 strings:
CString a = table+"."+fields[nField].name;
Uh The same code works fine in Windows XP. Any idea what I could do? I set WINVER=0x0501 in the compiling-settings (because the target-computers are mostly XP) and started Visual Studio as administrator.
Last edited by martho; September 14th, 2010 at 10:10 AM.
-
September 14th, 2010, 11:15 AM
#2
Re: Error in str_misaligned in application in Windows 7
Presumably this was a bug all along and the change to Windows 7 only exposed it. You should be glad; undetected bugs can have nasty and confusing consequences down the road.
Of course, it's impossible to say what the problem is without seeing more code around that location.
-
September 14th, 2010, 12:35 PM
#3
Re: Error in str_misaligned in application in Windows 7
 Originally Posted by martho
Hello!
I have developed a big application on Windows XP. Now I changed my OS to Windows 7 with a new computer.
I just copied the whole project and the settings of my Visual Studio 2005, and the compiling went well. But starting the application, I get an error
Unhandled exception at 0x5e8bb10c (msvcr80d.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0x000000fe
File strlen.asm:
Code:
str_misaligned:
; simple byte loop until string is aligned
mov al,byte ptr [ecx] <- Error
add ecx,1
test al,al
je short byte_3
test ecx,3
jne short str_misaligned
while just concate 2 strings:
CString a = table+"."+fields[nField].name;
Uh  The same code works fine in Windows XP. Any idea what I could do? I set WINVER=0x0501 in the compiling-settings (because the target-computers are mostly XP) and started Visual Studio as administrator.
It is actually 3 strings you want to concatenate. Can you tell what type the table and fields[nField].name is? And is nField a valid index or may it point beyond array boundaries?
-
September 14th, 2010, 12:42 PM
#4
Re: Error in str_misaligned in application in Windows 7
0xC0000005: Access violation reading location 0x000000fe
The 0x0x000000fe is too low to be a valid pointer (address). It looks as if a pointer to a struct/class is NULL and you were accessing a member at offset 0xfe from begin of the class.
Is it possible that 'fields' is a NULL pointer?
-
September 14th, 2010, 12:52 PM
#5
Re: Error in str_misaligned in application in Windows 7
 Originally Posted by martho
Uh  The same code works fine in Windows XP. Any idea what I could do?
Yes. Fix your code.
It doesn't matter if it ran fine in XP, because the code wasn't really running "fine" at all. There was always a bug, and as Lindley pointed out, the bug was exposed in Windows 7.
When you write a C++ application, and the application overwrites the boundaries of an array, misuses pointers, or similar faulty coding, nothing guarantees that the app will fail. That's the nature of C++ applications -- fauly coding doesn't mean you will see the fault when you run the program. Lucky for you, you now see that there is a problem.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; September 14th, 2010 at 06:42 PM.
-
September 14th, 2010, 02:41 PM
#6
Re: Error in str_misaligned in application in Windows 7
Thanks for your replys that put me into the right direction.
The code was okay, but a mysql-dll, which delivers the field-array, returns some null-pointers in Windows 7. Perhaps a mismatch of lib/dll (wrong pathes or a wrong version). I will check this further.
-
September 14th, 2010, 06:44 PM
#7
Re: Error in str_misaligned in application in Windows 7
 Originally Posted by martho
Thanks for your replys that put me into the right direction.
The code was okay, but a mysql-dll, which delivers the field-array, returns some null-pointers in Windows 7. Perhaps a mismatch of lib/dll (wrong pathes or a wrong version). I will check this further.
Still, the crash should not have occurred if you had proper error checking in the application.
You should be checking all of your return values to make sure they are valid before using them. If a function states it returns certain values, then your app should be checking the return values.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|