open-watcom / open-watcom-v2

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

lib crashes #1207

Closed adamyg closed 7 months ago

adamyg commented 10 months ago

Latest build, random crashes when running 'lib' commands. Issues related to command line parsing, when a large quoted list of objects files in given (e.g 1k in length).

Open Watcom C/C++ LIB Clone for 386 Version 2.0 beta Jan 12 2024 02:03:01 (32-bit)
Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1995-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See https://github.com/open-watcom/open-watcom-v2#readme for details.
jmalak commented 10 months ago

Please, give sample command line which exhibit the problem. What host system you are using?

Anyway command line length is not limited, but maximum token length is 260 bytes.

adamyg commented 10 months ago

Was an invalid command-line, assume a buffer overflow.

lib -nologo /OUT:d:/devl/build/lib.owc20/debug/libtest.lib "d:\devl\build\debug\libtest2\W16\pcre2_auto_possess.obj d:\devl\build\debug\libtest2\W16\pcre2_chartables.obj d:\devl\build\debug\libtest2\W16\pcre2_compile.obj d:\devl\build\debug\libtest2\W16\pcre2_config.obj d:\devl\build\debug\libtest2\W16\pcre2_context.obj d:\devl\build\debug\libtest2\W16\pcre2_convert.obj d:\devl\build\debug\libtest2\W16\pcre2_dfa_match.obj d:\devl\build\debug\libtest2\W16\pcre2_error.obj d:\devl\build\debug\libtest2\W16\pcre2_extuni.obj d:\devl\build\debug\libtest2\W16\pcre2_find_bracket.obj d:\devl\build\debug\libtest2\W16\pcre2_jit_compile.obj d:\devl\build\debug\libtest2\W16\pcre2_maketables.obj d:\devl\build\debug\libtest2\W16\pcre2_match.obj d:\devl\build\debug\libtest2\W16\pcre2_match_data.obj d:\devl\build\debug\libtest2\W16\pcre2_newline.obj d:\devl\build\debug\libtest2\W16\pcre2_ord2utf.obj d:\devl\build\debug\libtest2\W16\pcre2_pattern_info.obj d:\devl\build\debug\libtest2\W16\pcre2_script_run.obj d:\devl\build\debug\libtest2\W16\pcre2_serialize.obj d:\devl\build\debug\libtest2\W16\pcre2_string_utils.obj d:\devl\build\debug\libtest2\W16\pcre2_study.obj d:\devl\build\debug\libtest2\W16\pcre2_substitute.obj d:\devl\build\debug\libtest2\W16\pcre2_substring.obj d:\devl\build\debug\libtest2\W16\pcre2_tables.obj d:\devl\build\debug\libtest2\W16\pcre2_ucd.obj d:\devl\build\debug\libtest2\W16\pcre2_valid_utf.obj d:\devl\build\debug\libtest2\W16\pcre2_xclass.obj"

The instruction at 0x61705f32 referenced memory at 0x61705f32.
The memory could not be read.
Exception fielded by 0x00403e60
EAX=0x02165267 EBX=0x65726370 ECX=0x5c363157 EDX=0x5c327473
ESI=0x65746269 EDI=0x00000001 EBP=0x00000003 ESP=0x0019fb78
EIP=0x61705f32 EFL=0x00010212 CS =0x00000023 SS =0x0000002b
DS =0x0000002b ES =0x0000002b FS =0x00000053 GS =0x0000002b
Stack dump (SS:ESP)
0x72657474 0x6e695f6e 0x6f2e6f66 0x64206a62 0x65645c3a 0x625c6c76
0x646c6975 0x6265645c 0x6c5c6775 0x65746269 0x5c327473 0x5c363157
0x65726370 0x63735f32 0x74706972 0x6e75725f 0x6a626f2e 0x5c3a6420
0x6c766564 0x6975625c 0x645c646c 0x67756265 0x62696c5c 0x74736574
0x31575c32 0x63705c36 0x5f326572 0x69726573 0x7a696c61 0x626f2e65
0x3a64206a 0x7665645c 0x75625c6c 0x5c646c69 0x75626564 0x696c5c67
0x93bee900 0xfffffffe 0x0019fda8 0x6a012315 0x0000010c 0x00000420
0x02164e68 0x00000000 0x6a029658 0x00000000 0x00000000 0x6a029598
0x6a028f50 0x6a016ead 0x0019fda8 0x00000000 0x6a028fb0 0x6a016d78
0x6a028fb0 0x0019fda8 0x02165173 0x02165269 0x0000000f 0x6a02751c
0x6a010c82 0x0000000a 0x02164e68 0x02165173 0x00000000 0x6a006117
0x00000105 0x000003ff 0x00000003 0x00000001 0x021637b1 0x6a02751c
Fatal error: Unable to execute 'wlib'
jmalak commented 10 months ago

It looks like problem of MS LIB driver which call OW librarian. I suppose you have properly setup OW environment variables WATCOM and PATH. You use incorrect syntax for LIB driver, you have single argument as quoted list but each filename item from list should be separate argument.

jmalak commented 10 months ago

lib should do better filename check and report such incorrect data (check file existence) wlib should report wrong filename argument

jmalak commented 8 months ago

Now lib program check existence of each input file as for wildcard files that cannot pass to wlib incorrect file name. The response for wrong command line sample is as follow.

C:\dev\ow2test\rel\binnt>lib /nologo /OUT:d:/devl/build/lib.owc20/debug/libtest.
lib "d:\devl\build\debug\libtest2\W16\pcre2_auto_possess.obj d:\devl\build\debug
\libtest2\W16\pcre2_chartables.obj d:\devl\build\debug\libtest2\W16\pcre2_compil
e.obj d:\devl\build\debug\libtest2\W16\pcre2_config.obj d:\devl\build\debug\libt
est2\W16\pcre2_context.obj d:\devl\build\debug\libtest2\W16\pcre2_convert.obj d:
\devl\build\debug\libtest2\W16\pcre2_dfa_match.obj d:\devl\build\debug\libtest2\
W16\pcre2_error.obj d:\devl\build\debug\libtest2\W16\pcre2_extuni.obj d:\devl\bu
ild\debug\libtest2\W16\pcre2_find_bracket.obj d:\devl\build\debug\libtest2\W16\p
cre2_jit_compile.obj d:\devl\build\debug\libtest2\W16\pcre2_maketables.obj d:\de
vl\build\debug\libtest2\W16\pcre2_match.obj d:\devl\build\debug\libtest2\W16\pcr
e2_match_data.obj d:\devl\build\debug\libtest2\W16\pcre2_newline.obj d:\devl\bui
ld\debug\libtest2\W16\pcre2_ord2utf.obj d:\devl\build\debug\libtest2\W16\pcre2_p
attern_info.obj d:\devl\build\debug\libtest2\W16\pcre2_script_run.obj d:\devl\bu
ild\debug\libtest2\W16\pcre2_serialize.obj d:\devl\build\debug\libtest2\W16\pcre
2_string_utils.obj d:\devl\build\debug\libtest2\W16\pcre2_study.obj d:\devl\buil
d\debug\libtest2\W16\pcre2_substitute.obj d:\devl\build\debug\libtest2\W16\pcre2
_substring.obj d:\devl\build\debug\libtest2\W16\pcre2_tables.obj d:\devl\build\d
ebug\libtest2\W16\pcre2_ucd.obj d:\devl\build\debug\libtest2\W16\pcre2_valid_utf
.obj d:\devl\build\debug\libtest2\W16\pcre2_xclass.obj"
Open Watcom C/C++ LIB Clone for 386 Version 2.0 beta Feb 21 2024 02:44:46 (32-bi
t)
Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1995-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See https://github.com/open-watcom/open-watcom-v2#readme for details.
Fatal error: can't find following file: "d:\devl\build\debug\libtest2\W16\pcre2_
auto_possess.obj d:\devl\build\debug\libtest2\W16\pcre2_chartables.obj d:\devl\b
uild\debug\libtest2\W16\pcre2_compile.obj d:\devl\build\debug\libtest2\W16\pcre2
_config.obj d:\devl\build\debug\libtest2\W16\pcre2_context.obj d:\devl\build\deb
ug\libtest2\W16\pcre2_convert.obj d:\devl\build\debug\libtest2\W16\pcre2_dfa_mat
ch.obj d:\devl\build\debug\libtest2\W16\pcre2_error.obj d:\devl\build\debug\libt
est2\W16\pcre2_extuni.obj d:\devl\build\debug\libtest2\W16\pcre2_find_bracket.ob
j d:\devl\build\debug\libtest2\W16\pcre2_jit_compile.obj d:\devl\build\debug\lib
test2\W16\pcre2_maketables.obj d:\devl\build\debug\libtest2\W16\pcre2_match.obj
d:\devl\build\debug\libtest2\W16\pcre2_match_data.obj d:\devl\build\debug\libtes
t2\W16\pcre2_newline.obj d:\devl\build\debug\libtest2\W16\pcre2_ord2utf.obj d:\d
evl\build\debug\libtest2\W16\pcre2_pattern_info.obj d:\devl\build\debug\libtest2
\W16\pcre2_script_run.obj d:\devl\build\debug\libtest2\W16\pcre2_serialize.obj d
:\devl\build\debug\libtest2\W16\pcre2_string_utils.obj d:\devl\build\debug\libte
st2\W16\pcre2_study.obj d:\devl\build\debug\libtest2\W16\pcre2_substitute.obj d:
\devl\build\debug\libtest2\W16\pcre2_substring.obj d:\devl\build\debug\libtest2\
W16\pcre2_tables.obj d:\devl\build\debug\libtest2\W16\pcre2_ucd.obj d:\devl\buil
d\debug\libtest2\W16\pcre2_valid_utf.obj d:\devl\build\debug\libtest2\W16\pcre2_
xclass.obj"

C:\dev\ow2test\rel\binnt>
jmalak commented 7 months ago

it is fixed now