open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
992 stars 163 forks source link

wlink memory could not be read error #1338

Closed Pokeman2003 closed 1 month ago

Pokeman2003 commented 1 month ago

I tried to compile this source code I've been experimenting with using a pretty standard IDE directory, but Resource/M_Main.rc, by all accounts a very standard resource script, causes WRC to crash with a "this memory could not be read" error. For what it's worth, the path that I put this folder in(...\Documents\Projects\Win32 Experiment\Source) has exactly one space, which may be resulting in the crash.

Okay, I somehow misidentified the program that was crashing. None the less, wlink is still crashing, and it looks like the resource files might be involved because removing the RC files from the IDE will cause it to successfully link.

What a trainwreck, I am so sorry for screwing up my original issue. This is the current IDE directory as it stands right now. Crash log: cd "C:\Users\Personal\Documents\Projects\Win32 Experiment" wmake -f "C:\Users\Personal\Documents\Projects\Win32 Experiment\Experimentation.mk" -h -e "C:\Users\Personal\Documents\Projects\Win32 Experiment\OUT\SimpleText.exe" cd "C:\Users\Personal\Documents\Projects\Win32 Experiment\OUT" wcc386 ..\Source\Entry.c -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od -d2 -6r -bt=nt -fo=.obj -mf ..\Source\Entry.c(10): Warning! W303: Parameter 'unused' has been defined, but not referenced ..\Source\Entry.c(10): Warning! W303: Parameter 'shown' has been defined, but not referenced ..\Source\Entry.c(10): Warning! W303: Parameter 'args' has been defined, but not referenced wcc386 ..\Source\Messages.c -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od -d2 -6r -bt=nt -fo=.obj -mf wcc386 ..\Source\Text.c -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od -d2 -6r -bt=nt -fo=.obj -mf wcc386 ..\Source\Windows\Classes.c -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od -d2 -6r -bt=nt -fo=.obj -mf wcc386 ..\Source\Windows\Main.c -i="C:\WATCOM/h;C:\WATCOM/h/nt" -w4 -e25 -zq -od -d2 -6r -bt=nt -fo=.obj -mf wrc ..\Source\Resource\D_About.rc -bt=nt -dWIN32 -d_WIN32 -d__NT__ -i="C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Resource\;C:\WATCOM/h;C:\WATCOM/h/nt" -q -ad -r -fo=D_About.res wrc ..\Source\Resource\Iconography.rc -bt=nt -dWIN32 -d_WIN32 -d__NT__ -i="C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Resource\;C:\WATCOM/h;C:\WATCOM/h/nt" -q -ad -r -fo=Iconography.res wrc ..\Source\Resource\M_Main.rc -bt=nt -dWIN32 -d_WIN32 -d__NT__ -i="C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Resource\;C:\WATCOM/h;C:\WATCOM/h/nt" -q -ad -r -fo=M_Main.res wlink name SimpleText d all sys nt_win op m op maxe=25 op q op symf @SimpleText.lk1 The instruction at 0x69c3598e referenced memory at 0x00000008.The memory could not be read.Exception fielded by 0x00403000EAX=0x00000000 EBX=0x0019fab8 ECX=0x02309ae0 EDX=0x0019fa78ESI=0x0019fa78 EDI=0x02309b10 EBP=0x0019fab8 ESP=0x0019fa54EIP=0x69c3598e EFL=0x00010212 CS =0x00000023 SS =0x0000002bDS =0x0000002b ES =0x0000002b FS =0x00000053 GS =0x0000002bStack dump (SS:ESP)0x00000000 0x00000000 0x023217d0 0x02309b10 0x02309af8 0x69c38c38 0x69c54d8c 0x023217d0 0x00000000 0x69c55494 0x02300000 0x02309b40 0x02309b28 0x02309af8 0x02309b10 0x02309b10 0x0019fab8 0x02309ae0 0x69c32bb3 0x0019fafc 0x0019fae4 0x0000a000 0x02309a18 0x69c32920 0x0019fc5c 0x00000000 0x02309a18 0x02309a18 0x0000a000 0x00000110 0x0019fc5c 0x00000200 0x02309a18 0x69c18bdd 0x00005a00 0x00000000 0x0000000c 0x0230c650 0x00000000 0x00000001 0x0019fc5c 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000 000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 Error(E14): Cannot execute (wlink): No error Error(E42): Last command making (C:\Users\Personal\Documents\Projects\Win32 Experiment\OUT\SimpleText.exe) returned a bad status Error(E02): Make execution terminated Execution complete

jmalak commented 1 month ago

I am sorry, but from the messages you can see that your project has redefinition of many symbols. I don't see any issue with wrc. It looks like mismatch in your project. As you see messages, wlink select one of symbol version, each can have different parameters etc. You need to check and fix it first.

Warning! W1027: file Classes.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Classes.c): redefinition of _executionHandle ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_ClassRegS ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_MasterRegS ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _wcMain ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_ClassRegT ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_ClassRegC ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_MasterRegT ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _MB_E_MasterRegC ignored 
Warning! W1027: file Main.obj(C:\Users\Personal\Documents\Projects\Win32 Experiment\Source\Windows\Main.c): redefinition of _executionHandle ignored

Anyway I need fully compilable sample including IDE project definition. The only sources is useless.

Pokeman2003 commented 1 month ago

Full Directory.zip Okay. This should be everything. I don't know what else you need.

I don't know what's causing the redefinition errors at all. For example: executionHandle only shows up in Win32.h, and yet Classes.c is complaining that I've somehow redefined it. It gets it from Windows/Windows.h. Not a single one of its other header files(Messages.h, Window/Classes.h, and Resource/Resources.h) includes Win32.h, it's only Windows/Windows.h. executionHandle isn't even USED in Classes.c, there should be no chance of redefinitions in the slightest.

jmalak commented 1 month ago

The duplicity is due to you use definition in header file instead of declaration.

You must define it in single object and in header file must be only declaration. By example for executionHandle in Win32.h you define it by HINSTANCE executionHandle;

but there should be declaration only as extern HINSTANCE executionHandle;

and definition only in one C source file by example in Entry.c HINSTANCE executionHandle;

Pokeman2003 commented 1 month ago

Cool, well that quirk is now fixed. Weird way of approaching that. I don't recall any other compilers that required me to do this, but then again I haven't coded in C for years at this point and I didn't get far last time.

If anyone wants the updated package, here you go. It'll reduce those warnings to dust... buuut I'm still suffering the same issue illegal instruction error. However, it looks like it's wlink now? It's Error #2.log now. Full Directory 2.zip

Edit: oh no

jmalak commented 1 month ago

Anyway it looks like as bug in wlink if multiple resource files are used and some of them are blank as in your test case. Normaly this issue is not happen because in real case you add non-blank resource file only. I will fix it.

To declaration/definition issue. It cannot be reported by C compiler because it is valid code. It is logical mistake which is reported by linker and it depends on what each linker report as error or warning etc.

jmalak commented 1 month ago

Anyway your IDE project is correct (relative paths) because I used it on my box on different path without problem.

jmalak commented 1 month ago

It should be fixed now. Download new build after build finish.

Pokeman2003 commented 1 month ago

Due to circumstances outside of my control, I couldn't download the build last night when you requested me to do the test. The most recent build, 2024-10-11, is spitting out the error "can not connect to batcher spawn server". I'm going to look into trying to compile your commit myself.

Pokeman2003 commented 1 month ago

The commit solved it, sweet!

For the record, the installer should probably get updated at some point to request closing EVERY executable found in the bin* folders before trying to selectively install or delete things. Turns out, my issue wasn't that the build was bad, it was that there were some leftover batchserv instances in the binnt folder.