Re: problem in using SampleFilterScheme
Re: problem in using SampleFilterScheme
- Subject: Re: problem in using SampleFilterScheme
- From: "Li Flost.Dexiong" <email@hidden>
- Date: Wed, 04 Jul 2012 10:57:33 +0800
thanks Phil,
I did call read by using getProvider()--> read(xxx).
I have another try this morning, but got another panic stack, this stack was quit small,
but still have "Double fault".and this time, the probe function could not finish and got panic.
the stack like this:
Wed Jul 4 10:37:15 2012
panic(cpu 0 caller 0x2aaf41): Double fault at 0x2a17c65e, thread:0x6adeb7c, trapno:0x8, err:0x0,registers:
CR0: 0x8001003b, CR2: 0x30c9fcc8, CR3: 0x00100000, CR4: 0x00000660
EAX: 0x00020000, EBX: 0x07fd3100, ECX: 0x2a17c64a, EDX: 0x2a17cd40
ESP: 0x30c9fcd0, EBP: 0x30ca0d18, ESI: 0x2a4bb2d2, EDI: 0x07fd5200
EFL: 0x00010202, EIP: 0x2a17c65e
Backtrace (CPU 0), Frame : Return Address (4 potential args on stack)
0x819e18 : 0x21b837 (0x5dd7fc 0x819e4c 0x223ce1 0x0)
0x819e68 : 0x2aaf41 (0x59dfe4 0x59e0df 0x2a17c65e 0x6adeb7c)
0x819f58 : 0x2a29d2 (0x0 0x0 0x0 0x0)
0x30ca0d18 : 0x2a17c766 (0x7fd3e80 0x7fd2400 0x20000 0x0) com_apple_dts_driver_SampleFilterScheme::read(IOService*, unsigned long long, IOMemoryDescriptor*, IOStorageAttributes*, IOStorageCompletion*)+284>: add $0x1040,%esp
0x30ca1d68 : 0x2a17c766 (0x7fd3100 0x7fd2500 0x20000 0x0) com_apple_dts_driver_SampleFilterScheme::read(IOService*, unsigned long long, IOMemoryDescriptor*, IOStorageAttributes*, IOStorageCompletion*)+284
0x30ca2db8 : 0x2a4c111e (0x7fd5f00 0x7fd4f00 0x20000 0x0) IOStorage::read(IOService*, unsigned long long, IOMemoryDescriptor*, unsigned long long*)+88
0x30ca2e08 : 0x2a17c9b1 (0x7fd4f00 0x7fd5200 0x20000 0x0) com_apple_dts_driver_SampleFilterScheme::probe(IOService*, long*)+407
0x30ca3e78 : 0x541e8f (0x7fd5200 0x7fd4f00 0x30ca3f0c 0x70e6000)
0x30ca3f28 : 0x5426e9 (0x7fd4f00 0x709d7c0 0x0 0xffffffff)
0x30ca3f78 : 0x5443d5 (0x7fd4f00 0x0 0x30ca3fac 0x1)
0x30ca3fc8 : 0x2a179c (0x6834470 0x0 0x2a17ab 0x401aee4)
Kernel Extensions in backtrace (with dependencies):
com.apple.dts.driver.SampleFilterScheme(1.2.0d1)@0x2a17b000->0x2a17dfff
dependency: com.apple.iokit.IOStorageFamily(1.6.3)@0x2a4af000
com.apple.iokit.IOStorageFamily(1.6.3)@0x2a4af000->0x2a4c7fff
My change like this:
1) add a probe function to SampleFilterScheme; this function implement as description in my last mail.
2) modify read function declaration to
virtual void read(IOService* client,
UInt64 byteStart,
IOMemoryDescriptor* buffer,
IOStorageAttributes* attributes,
IOStorageCompletion * completion);
and its implementation is:
void com_apple_dts_driver_SampleFilterScheme::read(IOService* __attribute__ ((unused)) client,
UInt64 byteStart,
IOMemoryDescriptor* buffer,
IOStorageAttributes* attributes,
IOStorageCompletion *completion)
{
char pname[4096] = {'\0'};
proc_selfname(pname, sizeof(pname));
DEBUG_LOG("%s[%p]::%s(%p, %llu, %p, %p, %p)\n", getName(), this, __FUNCTION__, client, byteStart, buffer, completion);
printf("%s->%s[%p]::%s(%p, %llu, %p, %p)\n",pname, getName(), this, __FUNCTION__, client, byteStart, buffer, completion);
getProvider()->read(this, byteStart, buffer, attributes, completion);
}
I'm curious about
1) why the GetProvider() will turn back to my class?
2) if the stack is small to 16KB, but in my probe function, i just using a array of 4096B. how can this be overflow?
在 2012-7-3,下午9:05, Phil Jordan 写道:
> On Mon, Jul 2, 2012 at 5:53 PM, Flost Li <email@hidden> wrote:
>> Hi all,
>>
>> I download the SampleFilterScheme example code from
>> https://developer.apple.com/library/mac/#samplecode/SampleFilterScheme/Introduction/Intro.html#//apple_ref/doc/uid/DTS10000432
>> But I have some issue on making study on it.
>>
>> I modify the code downloaded, and add the "probe" method. This probe
>> function will scan a scsi disk and check whether it contains certain string
>> on certain offset. If the probe function got the string, the function will
>> return a score of 9999.
>>
>> I build the project, insert this kext, and than i connect my device.
>> from the log, i notice that the disk was recognize by the kext, and the kext
>> started.
>> but soon after the driver start, the system got panic. when i restart the
>> machine, and use gdb/kextutils to decode the panic stack sounds like below:
>> (as the first several level are the same, i only print the first 7 level of
>> the stack.)
>
> I can only guess, as you haven't provided any code, but:
>
> You need to call the read() method *on the provider IOMedia object*
> (your underlying disk/partition) in your read() method. It looks like
> you're calling this->read() or IOStorage::read() instead.
>
>> I'm wandering why the iokit got recursive status? does the panic called by
>> the over stack, when the recursive for much time?
>
> Notice the "Double fault" - this almost always means you've hit a
> stack overflow. Kernel stacks are only a little under 16KiB on OSX, so
> they're very easy to blow, not that a bigger stack would have helped
> in this case, as the recursion would probably have carried on forever.
>
> Hope that helps,
> phil
Best regards,
Flost.D.Li
email@hidden
_______________________________________________
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