linux-msdos.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* DOSEMU fails on start with SIGSEGV...
@ 2023-07-30 12:41 Zeni Junker
  2023-07-30 16:22 ` Zeni Junker
  2023-07-30 19:02 ` stsp
  0 siblings, 2 replies; 5+ messages in thread
From: Zeni Junker @ 2023-07-30 12:41 UTC (permalink / raw)
  To: linux-msdos

I'm running Gentoo ( if that matters)
I've tried with version 1.4.0 and latest from git repo and the result is the same.
Also, it fails the same way whether I start it as a root or ordinary user ( I've added lines for both in dosemu.usrs file: "username/root c_all" ).

So I've compiled it with "debug" option tried to debug it with gdb.

Well, this has lead me through the initialization.

Thing is in main() (in emu.c - line 394) low_mem_init getc called and it fails.

Peeking within it shows that low_mem_init ( init.c) calls alloc_mapping ( line  261), which fails.

Peek into alloc_mapping ( file mapping.c) fails in line 419,, when it tries to copy pointer to allocated area to lowmem_base, which is 0 at that point:
line 419: " *(char **)(&lowmem_base) = addr; "

Since low memory has never been allocated at that point, this causes SIGSEGV.

At some point I thought this might be due to some kernel protection etc. Setting in/proc/sys/vm/mmap_min_addr was 65536, so I've reset it to 0 and retried, with the same result.

Then I've noticed that lowmem_base gets declared as "char * const lowmem_base" in mapping.c and nothing ever sets it, so it is always 0.
Just to doublecheck, I've inspected /proc/proc_id/maps of debugged process and indeed there was nothing mapped at address 0 - all I've seen are high address map areas that one usually gets from mmap
in the range 0x7Fxxxxxxxx for various libs etc and 4 mappings of dosemu.bin, also at high adresses.
But nothing low, so naturally any acess outside of mapped areas SIGSEGVs.

So, my question is, am I missing something ?

Shouldn't lowmem_base be set somewhere ?
If not, shouldn't the low area be mapped in somewhere before that ?

TIA,

Zeni


-- 
Sent with https://mailfence.com  
Secure and private email

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: DOSEMU fails on start with SIGSEGV...
  2023-07-30 12:41 DOSEMU fails on start with SIGSEGV Zeni Junker
@ 2023-07-30 16:22 ` Zeni Junker
  2023-07-30 19:02 ` stsp
  1 sibling, 0 replies; 5+ messages in thread
From: Zeni Junker @ 2023-07-30 16:22 UTC (permalink / raw)
  To: linux-msdos

Nevermind.

It looks like gcc-12+ has problems with static const declarations for lowmem_base and mem_base, especcially as they get defined later,  so
I've erased "const" in both definitions ( and extern declarations) and now it works, or at least so it seems.




> ----------------------------------------
> From: Zeni Junker <zeni.junker445@mailfence.com>
> Date: Jul 30, 2023, 12:41:16 PM
> To: <linux-msdos@vger.kernel.org>
> Subject: DOSEMU fails on start with SIGSEGV...
> 
> 
> I'm running Gentoo ( if that matters)
> I've tried with version 1.4.0 and latest from git repo and the result is the same.
> Also, it fails the same way whether I start it as a root or ordinary user ( I've added lines for both in dosemu.usrs file: "username/root c_all" ).
> 
> So I've compiled it with "debug" option tried to debug it with gdb.
> 
> Well, this has lead me through the initialization.
> 
> Thing is in main() (in emu.c - line 394) low_mem_init getc called and it fails.
> 
> Peeking within it shows that low_mem_init ( init.c) calls alloc_mapping ( line  261), which fails.
> 
> Peek into alloc_mapping ( file mapping.c) fails in line 419,, when it tries to copy pointer to allocated area to lowmem_base, which is 0 at that point:
> line 419: " *(char **)(&lowmem_base) = addr; "
> 
> Since low memory has never been allocated at that point, this causes SIGSEGV.
> 
> At some point I thought this might be due to some kernel protection etc. Setting in/proc/sys/vm/mmap_min_addr was 65536, so I've reset it to 0 and retried, with the same result.
> 
> Then I've noticed that lowmem_base gets declared as "char * const lowmem_base" in mapping.c and nothing ever sets it, so it is always 0.
> Just to doublecheck, I've inspected /proc/proc_id/maps of debugged process and indeed there was nothing mapped at address 0 - all I've seen are high address map areas that one usually gets from mmap
> in the range 0x7Fxxxxxxxx for various libs etc and 4 mappings of dosemu.bin, also at high adresses.
> But nothing low, so naturally any acess outside of mapped areas SIGSEGVs.
> 
> So, my question is, am I missing something ?
> 
> Shouldn't lowmem_base be set somewhere ?
> If not, shouldn't the low area be mapped in somewhere before that ?
> 
> TIA,
> 
> Zeni
> 
> 
> -- 
> Sent with https://mailfence.com  
> Secure and private email


-- 
Sent with https://mailfence.com  
Secure and private email

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: DOSEMU fails on start with SIGSEGV...
  2023-07-30 12:41 DOSEMU fails on start with SIGSEGV Zeni Junker
  2023-07-30 16:22 ` Zeni Junker
@ 2023-07-30 19:02 ` stsp
  2023-07-31  0:40   ` Zeni Junker
  1 sibling, 1 reply; 5+ messages in thread
From: stsp @ 2023-07-30 19:02 UTC (permalink / raw)
  To: Zeni Junker, linux-msdos


30.07.2023 17:41, Zeni Junker пишет:
> I'm running Gentoo ( if that matters)
> I've tried with version 1.4.0 and latest from git repo and the result is the same.
> Also, it fails the same way whether I start it as a root or ordinary user ( I've added lines for both in dosemu.usrs file: "username/root c_all" ).
>
> So I've compiled it with "debug" option tried to debug it with gdb.
>
> Well, this has lead me through the initialization.
>
> Thing is in main() (in emu.c - line 394) low_mem_init getc called and it fails.
>
> Peeking within it shows that low_mem_init ( init.c) calls alloc_mapping ( line  261), which fails.
>
> Peek into alloc_mapping ( file mapping.c) fails in line 419,, when it tries to copy pointer to allocated area to lowmem_base, which is 0 at that point:
> line 419: " *(char **)(&lowmem_base) = addr; "
>
> Since low memory has never been allocated at that point, this causes SIGSEGV.
>
> At some point I thought this might be due to some kernel protection etc. Setting in/proc/sys/vm/mmap_min_addr was 65536, so I've reset it to 0 and retried, with the same result.
>
> Then I've noticed that lowmem_base gets declared as "char * const lowmem_base" in mapping.c and nothing ever sets it, so it is always 0.
> Just to doublecheck, I've inspected /proc/proc_id/maps of debugged process and indeed there was nothing mapped at address 0 - all I've seen are high address map areas that one usually gets from mmap
> in the range 0x7Fxxxxxxxx for various libs etc and 4 mappings of dosemu.bin, also at high adresses.
> But nothing low, so naturally any acess outside of mapped areas SIGSEGVs.
>
> So, my question is, am I missing something ?
Some googling, as usual.
It would give you this dosemu2 ebuild:

https://gpo.zugaina.org/app-emulation/dosemu2/RDep

Or an 1.4.0.8 update for dosemu1.
Good that you've found your own solution
and got a 20-years-old software working,
but you certainly could do it otherwise.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: DOSEMU fails on start with SIGSEGV...
  2023-07-30 19:02 ` stsp
@ 2023-07-31  0:40   ` Zeni Junker
  2023-07-31  7:36     ` stsp
  0 siblings, 1 reply; 5+ messages in thread
From: Zeni Junker @ 2023-07-31  0:40 UTC (permalink / raw)
  To: linux-msdos



> ----------------------------------------
> From: stsp <stsp2@yandex.ru>
> Date: Jul 30, 2023, 7:02:05 PM
> To: Zeni Junker <zeni.junker445@mailfence.com>, <linux-msdos@vger.kernel.org>
> Subject: Re: DOSEMU fails on start with SIGSEGV...
> 
> 
> 
> 30.07.2023 17:41, Zeni Junker пишет:
> > I'm running Gentoo ( if that matters)
> > I've tried with version 1.4.0 and latest from git repo and the result is the same.
> > Also, it fails the same way whether I start it as a root or ordinary user ( I've added lines for both in dosemu.usrs file: "username/root c_all" ).
> >

<SNIP>

> >
> > So, my question is, am I missing something ?
> Some googling, as usual.
> It would give you this dosemu2 ebuild:
> 
> https://gpo.zugaina.org/app-emulation/dosemu2/RDep
> 
> Or an 1.4.0.8 update for dosemu1.
> Good that you've found your own solution
> and got a 20-years-old software working,
> but you certainly could do it otherwise.
> 

True. I've found dosemu2 page, but it looked as an alternative, somewhat experimental fork .
Also, portage tree doesn't have dosemu2, just dosemu1, so I've surmised that dosemu should work and 
I remember using it years ago.

I've also asked on Gentoo infra and got a meak, but positive response that dosemu should work.

I'll try dosemu2, but in the end, it's nice to know that I could get to a working solution by myself.
It also didn't hurt to refresh my basic gdb skills.

TIA.


-- 
Sent with https://mailfence.com  
Secure and private email

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: DOSEMU fails on start with SIGSEGV...
  2023-07-31  0:40   ` Zeni Junker
@ 2023-07-31  7:36     ` stsp
  0 siblings, 0 replies; 5+ messages in thread
From: stsp @ 2023-07-31  7:36 UTC (permalink / raw)
  To: Zeni Junker, linux-msdos


31.07.2023 05:40, Zeni Junker пишет:
>>> So, my question is, am I missing something ?
>> Some googling, as usual.
>> It would give you this dosemu2 ebuild:
>>
>> https://gpo.zugaina.org/app-emulation/dosemu2/RDep
>>
>> Or an 1.4.0.8 update for dosemu1.
>> Good that you've found your own solution
>> and got a 20-years-old software working,
>> but you certainly could do it otherwise.
>>
> True. I've found dosemu2 page, but it looked as an alternative, somewhat experimental fork .

... full rewrite, and so on.
All is true.
We try to provide the basic dosemu1
compatibility, but its just "basic". :)

> Also, portage tree doesn't have dosemu2, just dosemu1, so I've surmised that dosemu should work and
> I remember using it years ago.
>
> I've also asked on Gentoo infra and got a meak, but positive response that dosemu should work.
>
> I'll try dosemu2, but in the end, it's nice to know that I could get to a working solution by myself.
> It also didn't hurt to refresh my basic gdb skills.
I suppose that dosemu1 has a very little
use today, so its not that unlikely that your
gdb efforts in that area are not interesting
for anything else but refreshing the gdb
skills. :) It keeps disappearing from distros,
AFAIK even debian recently dropped it, so
I don't think the fact that it still works on
gentoo, will last for long enough.
And dosemu2 is not yet interesting for distributions
like gentoo, because its build process is awkward
and the releases are infrequent and not well
tested (yet). But its already good enough for
the end-users who can build from git.
So you may want to try dosbox instead, or
you may want to share your gdb skills with
the dosemu2 project.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-31  7:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-30 12:41 DOSEMU fails on start with SIGSEGV Zeni Junker
2023-07-30 16:22 ` Zeni Junker
2023-07-30 19:02 ` stsp
2023-07-31  0:40   ` Zeni Junker
2023-07-31  7:36     ` stsp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).