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

wlib segmentation fault #1241

Closed sezero closed 5 months ago

sezero commented 8 months ago

Something seems to have broken between yesterday's and today's 'Current-build'

This is from a CI workflow run on a windows host:

    wlib -q -b -n -c -pa -s -t -zld -ii -io -inn libxmp.lib +libxmp.dll
The instruction at 0x6a00945d referenced memory at 0x0008d18c.
The memory could not be written.
Exception fielded by 0x00403e60
EAX=0x02308a1c EBX=0x00000000 ECX=0x0008d18c EDX=0x0008d0e0
ESI=0x0019fa4d EDI=0x6a005001 EBP=0x02264798 ESP=0x0019fa10
EIP=0x6a00945d EFL=0x00010202 CS =0x00000023 SS =0x0000002b
DS =0x0000002b ES =0x0000002b FS =0x00000053 GS =0x0000002b
Stack dump (SS:ESP)
0x6a027508 0x00000007 0x00000000 0x6a005410 0x02308a24 0x00000000 
0x65e038bc 0x00000000 0x000081b6 0x0008b200 0x6a011400 0x00000000 
0x00000000 0x0019fe4c 0x6a005030 0x00805a4d 0x00000001 0x6a005230 
0x6a028402 0x0019fe4c 0x0019fa70 0x02264356 0x02264340 0x6a00553c 
0x7862696c 0x642e706d 0x00006c6c 0x00488090 0x00000000 0x0000000e 
0x00000001 0x00000000 0x007202cc 0x00000001 0x004896e0 0x00000000 
0x00000000 0x004880e8 0x0e00000e 0x0000000c 0x00000000 0x00000002 
0x007202ac 0x00000000 0x01010000 0x00000030 0x00000000 0x00488098 
0x0000007f 0x00720270 0x0000000c 0x00000000 0x00000000 0x000e0000 
0x00720270 0x0000000c 0x0000000c 0x004880e0 0x01000000 0x0000000c 
0x00000000 0x00000000 0x0019ff60 0x7748c420 0x44532416 0xfffffffe 
0x0019fb7c 0x7749d047 0x00000000 0x7749d06d 0x00488098 0x00720000 
Error(E14): Cannot execute (wlib): No error
Error(E42): Last command making (libxmp.dll) returned a bad status
Error(E02): Make execution terminated
Should this file be deleted [Yes/No] ? 
Error: Process completed with exit code 1.

Happens on linux, as well:

    wlib -q -b -n -c -pa -s -t -zld -ii -io -inn libxmp.lib +libxmp.dll
Segmentation fault
Error(E42): Last command making (libxmp.dll) returned a bad status
jmalak commented 8 months ago

Thanks for your bug report. I will fix it ASAP.

jmalak commented 8 months ago

Please could you give me copy of libxmp.dll.

sezero commented 8 months ago

Here you go (both built with ow1.9): win32dll.zip, os2dll.zip

sezero commented 8 months ago

Here you go (both built with ow1.9): win32dll.zip, os2dll.zip

Curiously, the segfault happens only with the win32 dll and not with the os/2 dll...

jmalak commented 8 months ago

Thanks I see what problem is. It is related to deallocation of output library name which is replaced during importing records to already dealocated memory block. It happens only for Windows target library and when create it from DLL by import records. It is part of code that need review it is not transparent code and there are changed pointers during processing between short module name and full path file name. I add transparent deallocation for short module name but it is changed (internaly during importing symbols from Windows DLL) and now fail if wlib do cleanup. I temporary remove this deallocation and after fixing importing import records from DLL I wll add it again.

sezero commented 8 months ago

The 'Last-CI-build' from https://github.com/open-watcom/open-watcom-v2/commit/79e1b3d52a8e97800c8f34e86e671d44182e6060 does seem to have worked around the issue.

jmalak commented 8 months ago

Thanks for confirmation. I will do permanent fix later. I think little rework import records handling for library will be necessary.

jmalak commented 5 months ago

I finished with librarian (wlib) code review and various fixes for buffer overflow etc.