Hello,
using my ugly hack to do file i/o from a module, I discovered some
problem calling mmap() from a function with a lot of local buffers
defined. I have:
char * pizda_malloc(struct proc *p, int size)
{
struct mmap_args mem; int res; register_t save; char *buf;
save = p->p_retval[0];
mem.addr = NULL;
mem.len = size;
mem.prot = PROT_READ | PROT_WRITE;
mem.flags = MAP_ANON;
mem.fd = -1;
mem.pad = 0;
mem.pos = 0;
res = mmap(p, &mem);
if (res)
{
p->p_retval[0] = save;
return NULL;
}
buf = (char *)p->p_retval[0];
p->p_retval[0] = save;
subyte(buf, 0);
return buf;
}
I call this function with (curproc, PATH_MAX+1), and everything is fine
when I have just a few local variables defined in the caller (it all
works on MOD_LOAD only). However, if I have 2 buffers, 4096 bytes each,
as local variables and then try to allocate userspace memory the same
way, kernel crashes - sometimes inside mmap(), sometimes a bit later.
Why could this happen ? Is it related to possible stack overflow ?
(Yes, I know I can use MALLOC instead of static buffers, but I love
to understand what happens ...)
Regards,
Eugene
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message