News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

UASM32 Debug Bugs - fatal error LNK1171 - fatal error LNK1136

Started by LiaoMi, August 26, 2018, 11:13:35 PM

Previous topic - Next topic

LiaoMi

Hi,

programs with debugging information can't be compiled into an executable file, tried a lot of options, none of them led to success  :(

Build_uasm32_NoSuccess_x32_Link.bat
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 44 lines, 2 passes, 454 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

mywindow1.obj : fatal error LNK1136: invalid or corrupt file
Press any key to continue . . .


Build_uasm32_NoSuccess_x32_OldLink_.bat
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 44 lines, 2 passes, 477 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : warning LNK4044: unrecognized option "ASSEMBLYDEBUG"; ignored
mywindow1.obj : warning LNK4033: converting object format from OMF to COFF
mywindow1.obj : error LNK2001: unresolved external symbol _MessageBoxA@16
mywindow1.obj : error LNK2001: unresolved external symbol _ExitProcess@4
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
mywindow1.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.lst
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.res
Press any key to continue . . .


Build_uasm32_NoSuccess_x32_OldLink_PLUSParam.bat
UASM v2.46, Mar 26 2018, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 44 lines, 2 passes, 493 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

mywindow1.obj : error LNK2001: unresolved external symbol _ExitProcess@4
mywindow1.obj : error LNK2001: unresolved external symbol _MessageBoxA@16
mywindow1.exe : fatal error LNK1120: 2 unresolved externals
Press any key to continue . . .


Build_uasm32_NoSuccess_x64_Link.bat
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 44 lines, 2 passes, 468 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1171: unable to load mspdb140.dll (error code: 126)
Press any key to continue . . .


Build_uasm64_NoSuccess_x32_Link.bat
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 44 lines, 2 passes, 411 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

mywindow1.obj : fatal error LNK1136: invalid or corrupt file
Press any key to continue . . .


And here's another strange cut

invoke MessageBox,0,chr$("Test UASM Debug Compiling."),chr$("Test"),0

Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm(32) : Error A2275: Constant value too large: 54657374205541534D20446562756720h
mywindow1.asm(32) : Error A2147: Too few arguments to INVOKE: MessageBoxA
mywindow1.asm: 44 lines, 1 passes, 417 ms, 0 warnings, 2 errors


; -----------------------------------------
  ; non branching version with no ELSE clause
  ; -----------------------------------------
      chr$ MACRO any_text:VARARG
        LOCAL txtname
        .data
          IFDEF __UNICODE__
            WSTR txtname,any_text
            align 4
            .code
            EXITM <OFFSET txtname>
          ENDIF

          txtname db any_text,0
          align 4
          .code
          EXITM <OFFSET txtname>
      ENDM


Is there any idea how to solve it?

fearless

For debugging i use the following versions and flags:

x86:

Masm (ML.EXE) - Microsoft (R) Macro Assembler Version 6.14.8444 or Uasm (UASM32.EXE) - UASM v2.46, Dec  8 2017:/c /coff /Cp /Zi /Zd /nologo /I"x:\path to include files" filename.obj

Linker x86 version (LINK.EXE) - Microsoft (R) Incremental Linker Version 12.00.31101.0/SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"filename.pdb" /VERSION:4.0 /LIBPATH:"x:\path to lib files" /OUT:"filename.exe" filename.obj filename.res

Resource Compiler x86 version (RC.EXE) - Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17298/v filename.rc




x64:

Uasm (UASM64.EXE) - UASM v2.46, Dec  8 2017
/c -win64 -Zp8 /Zi /Zd /win64 /D_WIN64 /Cp /nologo /W2 /I"x:\path to include files" filename.obj

Linker x64 version (LINK.EXE) - Microsoft (R) Incremental Linker Version 12.00.31101.0
/SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV /PDB:"filename.pdb" /VERSION:4.0 /MACHINE:X64 /LIBPATH:"x:\path to lib files" /OUT:"filename.exe" filename.obj filename.res

Resource Compiler x64 version (RC.EXE) - Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17298/v filename.rc




I packaged my bin folders for the x86 or x64 link, lib, rc and other required dll's if thats any help:

       
  • x86 https://www.dropbox.com/s/ycvxwkiroevo8ii/ml_bin.zip?dl=0
  • x64 https://www.dropbox.com/s/zhsk655k3oyn7xk/uasm_bin.zip?dl=0

LiaoMi

Hi fearless,

I checked a number of linkers from different versions, even the last linker from Visual Studio 2017 works well, the condition for this is that there is no process in memory mspdbsrv.exe. New versions of the linker require a mspdbsrv.exe process for the debug mode compilation, if its running, then errors appear immediately. Thanks for your help! Closing this process, you can easily compile further with debug information by any linker.

mywindow1.obj : fatal error LNK1136: invalid or corrupt file
LINK : fatal error LNK1171: unable to load mspdb140.dll (error code: 126)
mywindow1.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info

Blocked build tree cleanup
The first problem was easy to track down. I guessed that the clean step was failing because some process still had an open file handle to one of the files or directories that the worker was trying to delete. I used the Windows 'Resource Monitor' application (resmon.exe), which can be launched from the 'Start' menu or from 'Task Manager', to find the offending process. The 'CPU' tab lets you search all open file handles on the system by filename, and I quickly discovered that mspdbsrv.exe was holding a file handle to one of the build directories.

What is mspdbsrv?
mspdbsrv is a helper service used by the Visual Studio C and C++ compiler, cl.exe; it collects debugging information for code that's being compiled and writes out .pdb databases. CL automatically spawns mspdbsrv if debug info is being generated and it connect to an existing instance. When the build completes, CL doesn't clean up any mspdbsrv that it spawned; it just leaves it running. There's no way to prevent CL from doing this.

So, it looked like the abandoned mspdbsrv instance had its current working directory set to one of the directories that the build worker was trying to delete, and on Windows you can't delete a directory if there's a process running there. So much for the first problem.

Build step timeouts
The second issue was more subtle -- but it also appeared to be due to the lingering mspdbsrv process! I noticed that mspdbsrv was actually holding a file handle to one of the buildbot worker's internal log files. It appears that buildbot doesn't close file handles when starting build processes, and these handles were being inherited by mspbdsrv, which was holding them open. As result, the buildbot worker (correctly) inferred that there were still unfinished build job processes running, and didn't report the build as completed.

Mismatched MSVC versions
When I thought through this a bit further, I realised there was another problem being caused by lingering mspdbsrv instances. Some of the builds being handled by the Windows build workers need to use MSVC 2015, and some still need to use MSVC 2010. Each type of build should use the corresponding version of mspdbsrv, but by default CL always connects to any available service process.


http://blog.peter-b.co.uk/2017/02/stop-mspdbsrv-from-breaking-ci-build.html

Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 72 lines, 2 passes, 327 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.11.25548.2
Copyright (C) Microsoft Corporation.  All rights reserved.

mywindow1.obj : warning LNK4209: debugging information corrupt; recompile module; linking object as if no debug info
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.lst
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.res
Press any key to continue . . .



jj2007

If you need help with this, I can write a little proggie that closes Visual Studio as soon as it is started :P

LiaoMi

Quote from: jj2007 on August 29, 2018, 05:20:11 AM
If you need help with this, I can write a little proggie that closes Visual Studio as soon as it is started :P

Hi Jochen,

great idea, I dont use the Visual Studio editor, the example above shows the limitations of the mspdbsrv.exe work, in my case its a simple linking of the bat file. Several times this problem has been repeated with the hang of this program and then there are already known compilation errors. Its necessary to check somehow from the command file whether this process exists and then close the mspdbsrv.exe process. It's strange that no one has encountered such a problem, judging by the tests, it occurs on any computer, if you use the latest versions of the linker.

taskkill /f /im mspdbsrv.exe

SUCCESS: The process "mspdbsrv.exe" with PID 17920 has been terminated.
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 102 lines, 2 passes, 325 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.14.26433.3
Copyright (C) Microsoft Corporation.  All rights reserved.

Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.lst
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.res
Press any key to continue . . .


or

ERROR: The process "mspdbsrv.exe" not found.
Translated Windows SDK 10.0 32 bits
windef WIN_INTERNAL manque ENDIF
mywindow1.asm: 102 lines, 2 passes, 347 ms, 0 warnings, 0 errors
Microsoft (R) Incremental Linker Version 14.14.26433.3
Copyright (C) Microsoft Corporation.  All rights reserved.

SUCCESS: The process "mspdbsrv.exe" with PID 43872 has been terminated.
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.lst
Could Not Find E:\DATA\MASM64\HJWasm\Debug Bugs\*.res
Press any key to continue . . .