RE: Panic in OSMalloc??
RE: Panic in OSMalloc??
- Subject: RE: Panic in OSMalloc??
- From: "Vishal Shetye" <email@hidden>
- Date: Fri, 11 Jan 2008 12:45:54 +0530
Hi Brian,
Could you please explain what are the consequences of calling OSMalloc with
some spin lock held.
I'm using lck_spin_lock() to lock a global variable before OSMalloc and
release it once the item allocated has been added to a queue.
Besides returned NULL value, is there any other difference between
OSMalloc() and OSMalloc_noblock()?
In case OSMalloc_noblock() returns NULL can I try allocation immediately?
________________________________
Thanks
- vishal shetye
-----Original Message-----
From: Brian Bergstrand [mailto:email@hidden]
Sent: Monday, December 24, 2007 4:31 PM
To: Vishal Shetye
Cc: email@hidden
Subject: Re: Panic in OSMalloc??
You should not call OSMalloc while holding any lock. If you must do
this, then use OSMalloc_noblock() instead - but be prepared to deal
with NULL if the request can't be filled.
On Dec 24, 2007, at 8:40 AM, Vishal Shetye wrote:
> Hi,
>
> I've written a kext that listens on fileop scope. I'm using OSMalloc
> and OSFree for memory allocation/freeing.
> I'm getting "thread_invoke: preemption_level 1" panic. Following is
> the backtrace of panic.
> OSMalloc() is the last function my kext calls.
> An area that I suspect is,
> I'm using same "OSMalloc Tag" in different parts of my module which
> might call OSMalloc simultaneously.
> Do I have to malloc with some locking under such scenarios or is it
> handled by OSMalloc() as I can see
> calls to mutex_lock() and subsequently to lck_mtx_lock_wait().
>
> What might be the case wherein OSMalloc(), trying to wait will
> result in such a panic???
>
> Backtrace
>
> #0 Debugger (message=0x3bc46c "panic") at /SourceCache/xnu/
> xnu-792.9.72/osfmk/i386/AT386/model_dep.c:706
> #1 0x00128b5e in panic (str=0x3bcd50 "thread_invoke:
> preemption_level %d\n") at /SourceCache/xnu/xnu-792.9.72/osfmk/kern/
> debug.c:202
> #2 0x001350ce in thread_invoke (old_thread=0x29c7c78,
> new_thread=0x1b70000, reason=0) at /SourceCache/xnu/xnu-792.9.72/
> osfmk/kern/sched_prim.c:1287
> #3 0x0013572c in thread_block_reason (continuation=0,
> parameter=0x0, reason=0) at /SourceCache/xnu/xnu-792.9.72/osfmk/kern/
> sched_prim.c:1692
> #4 0x001357bd in thread_block (continuation=0) at /SourceCache/xnu/
> xnu-792.9.72/osfmk/kern/sched_prim.c:1714
> #5 0x0012f297 in lck_mtx_lock_wait (lck=0x13adcb8,
> holder=0x29cae58) at /SourceCache/xnu/xnu-792.9.72/osfmk/kern/
> locks.c:569
> #6 0x00194e4e in mutex_lock ()
> #7 0x00141242 in zalloc_canblock (zone=0x13adcb0, canblock=1) at /
> SourceCache/xnu/xnu-792.9.72/osfmk/kern/zalloc.c:638
> #8 0x0012d780 in kalloc_canblock (size=12, canblock=1) at /
> SourceCache/xnu/xnu-792.9.72/osfmk/kern/kalloc.c:256
> #9 0x0012df5f in OSMalloc (size=12, tag=0x2af7600) at /SourceCache/
> xnu/xnu-792.9.72/osfmk/kern/kalloc.c:263
> #10 0x1f5796fb in ?? ()
> #11 0x1f576c60 in ?? ()
> #12 0x1f573319 in ?? ()
> #13 0x0031810a in kauth_authorize_action (scope=0x1c1ca04,
> credential=0x26a7204, action=2, arg0=41112608, arg1=4746816, arg2=2,
> arg3=0) at /SourceCache/xnu/xnu-792.9.72/bsd/kern/
> kern_authorization.c:405
> #14 0x0031827e in kauth_authorize_fileop (credential=0x26a7204,
> action=2, arg0=41112608, arg1=4746816) at /SourceCache/xnu/
> xnu-792.9.72/bsd/kern/kern_authorization.c:550
> #15 0x0032710e in close_internal (p=0x2273000, fd=5, fp=0x1d8e5e0,
> flags=3) at /SourceCache/xnu/xnu-792.9.72/bsd/kern/kern_descrip.c:1043
> #16 0x003272ae in close (p=0x2273000, uap=0x25bef0c,
> retval=0x25bef50) at /SourceCache/xnu/xnu-792.9.72/bsd/kern/
> kern_descrip.c:985
> #17 0x0036de6c in unix_syscall (regs=0x29c7ef0) at /SourceCache/xnu/
> xnu-792.9.72/bsd/dev/i386/systemcalls.c:201
> #18 0x00197ff3 in lo_unix_scall ()
> Cannot access memory at address 0xbffffa98
> Cannot access memory at address 0xbffffa9c
>
Brian Bergstrand
<http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden