Date: Mon, 21 Jul 2003 01:57:59 +0200 From: Pawel Jakub Dawidek <nick@garage.freebsd.pl> To: freebsd-hackers@freebsd.org Cc: dillon@apollo.backplane.com Subject: VM problem... Message-ID: <20030720235759.GJ437@garage.freebsd.pl>
next in thread | raw e-mail | index | archive | help
--UUBKWyapWpFAak7q Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello hackers... I'll try to describe my problem carefully, maybe there will be someone who will be able to help me with this. Problem: Strage 'Bus errors'. What I'm doing? I allocate memory in process' vmspace with my version of obreak function. It is quite simlar to those from /sys/vm/vm_unix.c. end =3D vm->vm_daddr + ctob(vm->vm_dsize); my_obreak(vm, end + size); Now I'm marking newly allocated range as read-only (it is my version of vm_map_protect() function, but is really simlar to): my_vm_protect(&vm->vm_map, end, end + size, VM_PROT_READ); Now execve() for this process is called, so I can't remove this memory, because this range isn't in process' vmspace anymore (I believe, that it should be removed, by VM or execve()). Process forks and now something happends in child and parent quits with SIGBUS. I've add some debug to trapsignal() from /sys/kern/kern_sig.c. Now I'm able to list every entry from process' vm_map with this function: void show_entries(struct proc *p) { vm_map_entry_t entry; entry =3D p->p_vmspace->vm_map.hint; do { if ((entry->max_protection & VM_PROT_WRITE) =3D=3D 0) { printf("ENTRY:%u: %p-%p (%d:%d)\n", p->p_pid, (void *)entry->start, (void *)entry->end, entry->protection, entry->max_protection); } entry =3D entry->next; } while (entry !=3D p->p_vmspace->vm_map.hint); } So as you can see I'm listing every entry that isn't writable. This function is called when process is killed by kernel with SIGBUS. It shows me that only this region isn't writable: ENTRY:<PID>: 0-0xbfc00000 (0:0) Ok! But all my allocations starts with 0x8xxxxxxx. But core file that I get tells me, that: Cannot access memory at address 0xbfbffc20. If I change VM_PROT_READ to VM_PROT_ALL when calling my_vm_protect() everything is correct. There is no SIGBUS, but this region: 0-0xbfc00000 is still marked as not writable (and I really believe that it should be:)). So how my allocations and read-only stuff interact with those bus errors? PS. I'm CC-ing this to Matt Dillon also. I know he is quite busy now, but maybe he will be able to track this down. PS2. I'm talking about FreeBSD 4.x here. --=20 Pawel Jakub Dawidek pawel@dawidek.net UNIX Systems Programmer/Administrator http://garage.freebsd.pl Am I Evil? Yes, I Am! http://cerber.sourceforge.net --UUBKWyapWpFAak7q Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iQCVAwUBPxsshz/PhmMH/Mf1AQF9DAP/W89l82OIshQtIzjd1TPDXN7jTwlEZ3Yz 2Xi0hXkhtwWeJp/hng7thRN9QJpvH23naHRfTHj0kDymnRSWW09AUAnvyr0VqwIJ YDExkZiOQXr8Oa+jfY+s2T6g4tYlXMxUhgOUR5XAmyYvS+kgUQaPnMdruxAZ/lrx ounDrZHQjSo= =4GD6 -----END PGP SIGNATURE----- --UUBKWyapWpFAak7q--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030720235759.GJ437>