kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* geting weird semi-random panic on kmalloc
@ 2012-06-22  0:50 NorthPole
  2012-06-22 11:55 ` Jonathan Neuschäfer
  2012-06-22 16:18 ` Mulyadi Santosa
  0 siblings, 2 replies; 8+ messages in thread
From: NorthPole @ 2012-06-22  0:50 UTC (permalink / raw)
  To: kernelnewbies

Hello everyone

I'm making my first steps in the linux kernel developpement by trying to
add some functionality in a kernel module
I have a problem that I cant seem to grasp and would greatly appreciate any
help.

I have this piece of code: http://pastebin.com/igP7255S
which is called by this:

for(i=0;i<250;i++)
registerTvlv(i,0x01,1,&batadv_ogm_packet->gw_flags,bat_priv,batadv_ogm_packet);


This is supposed to add 250 distinct tlvs in the list
batadv_ogm_packet->gw_flags is used both above and bellow the invocation
and the module doesnt crash
the same stands for these two bat_priv and batadv_ogm_packet

when I run the kernel code on an open-wrt build for x86 which is run
virtualized under a standard qemu running on debian squeeze produces this
output
http://pastebin.com/tY3Vkzvw
(in short it prints everything as its supposed to do for a random number of
iterations between 3 and 24 and the the kernel oops happens)

But i cant understand why the problem seems to happen at the kmalloc line
(havent figured how to use gdb for open wrt kernel debugging yet so i'm
relying on  printk for debugging)


the qemu instance loads with these setings

screen qemu\
-no-acpi -m 128M \
-net vde,sock=num1.ctl,port=1 -net nic,macaddr=fe:fe:00:00:01:01 \
-net nic -net tap,ifname=tapwrt1,script=no,downscript=no \
-nographic \
num1.image

Thank you for your time and answers

Spyros
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120622/995f127e/attachment.html 

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

* geting weird semi-random panic on kmalloc
  2012-06-22  0:50 geting weird semi-random panic on kmalloc NorthPole
@ 2012-06-22 11:55 ` Jonathan Neuschäfer
  2012-06-22 12:06   ` NorthPole
  2012-06-22 16:18 ` Mulyadi Santosa
  1 sibling, 1 reply; 8+ messages in thread
From: Jonathan Neuschäfer @ 2012-06-22 11:55 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Jun 22, 2012 at 03:50:49AM +0300, NorthPole wrote:
> for(i=0;i<250;i++)
> registerTvlv(i,0x01,1,&batadv_ogm_packet->gw_flags,bat_priv,batadv_ogm_packet);

Have you asked the people at irc.freenode.org #batman?

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

* geting weird semi-random panic on kmalloc
  2012-06-22 11:55 ` Jonathan Neuschäfer
@ 2012-06-22 12:06   ` NorthPole
  0 siblings, 0 replies; 8+ messages in thread
From: NorthPole @ 2012-06-22 12:06 UTC (permalink / raw)
  To: kernelnewbies

yes but the guy who answered came back empty (it was midnight though)
their code is correct since i'm using the version they are shipping with
the kernel.

so the error is in my part but how can the kernel crash in a kmalloc?
I dont get it

On Fri, Jun 22, 2012 at 2:55 PM, Jonathan Neusch?fer
<j.neuschaefer@gmx.net>wrote:

> On Fri, Jun 22, 2012 at 03:50:49AM +0300, NorthPole wrote:
> > for(i=0;i<250;i++)
> >
> registerTvlv(i,0x01,1,&batadv_ogm_packet->gw_flags,bat_priv,batadv_ogm_packet);
>
> Have you asked the people at irc.freenode.org #batman?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120622/451dff9e/attachment.html 

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

* geting weird semi-random panic on kmalloc
  2012-06-22  0:50 geting weird semi-random panic on kmalloc NorthPole
  2012-06-22 11:55 ` Jonathan Neuschäfer
@ 2012-06-22 16:18 ` Mulyadi Santosa
  2012-06-22 16:27   ` NorthPole
  1 sibling, 1 reply; 8+ messages in thread
From: Mulyadi Santosa @ 2012-06-22 16:18 UTC (permalink / raw)
  To: kernelnewbies

Hi...

On Fri, Jun 22, 2012 at 7:50 AM, NorthPole <morfeas3000@gmail.com> wrote:
> when I run the kernel code on an open-wrt build for x86 which is run
> virtualized under a standard qemu running on debian squeeze produces this
> output
> http://pastebin.com/tY3Vkzvw
> (in short it prints everything as its supposed to do for a random number of
> iterations between 3 and 24 and the the kernel oops happens)

I have no idea on what kind of modification openwrt folks do on top of
Linux kernel, but there is a chance the kernel space smaller or change
the way slab/slub/slob allocator works. In essence, the crash might
happen due to memory shortage or something like that.

Can you force a backtrace?

PS: I see no kfree() on the pastebin, is that true?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* geting weird semi-random panic on kmalloc
  2012-06-22 16:18 ` Mulyadi Santosa
@ 2012-06-22 16:27   ` NorthPole
  2012-06-22 16:49     ` Mulyadi Santosa
  0 siblings, 1 reply; 8+ messages in thread
From: NorthPole @ 2012-06-22 16:27 UTC (permalink / raw)
  To: kernelnewbies

Hi...

The virtual machine is supposed to run on 128 mb ram and according to the
batman folks its more than enough

How can I force a backtrace?

(kfree is supposed to be called on the list after the desired number of
nodes is  allocated but it never gets there )

On Fri, Jun 22, 2012 at 7:18 PM, Mulyadi Santosa
<mulyadi.santosa@gmail.com>wrote:

> Hi...
>
> On Fri, Jun 22, 2012 at 7:50 AM, NorthPole <morfeas3000@gmail.com> wrote:
> > when I run the kernel code on an open-wrt build for x86 which is run
> > virtualized under a standard qemu running on debian squeeze produces this
> > output
> > http://pastebin.com/tY3Vkzvw
> > (in short it prints everything as its supposed to do for a random number
> of
> > iterations between 3 and 24 and the the kernel oops happens)
>
> I have no idea on what kind of modification openwrt folks do on top of
> Linux kernel, but there is a chance the kernel space smaller or change
> the way slab/slub/slob allocator works. In essence, the crash might
> happen due to memory shortage or something like that.
>
> Can you force a backtrace?
>
> PS: I see no kfree() on the pastebin, is that true?
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120622/34d7cf4e/attachment.html 

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

* geting weird semi-random panic on kmalloc
  2012-06-22 16:27   ` NorthPole
@ 2012-06-22 16:49     ` Mulyadi Santosa
  2012-06-25 23:22       ` NorthPole
  0 siblings, 1 reply; 8+ messages in thread
From: Mulyadi Santosa @ 2012-06-22 16:49 UTC (permalink / raw)
  To: kernelnewbies

Hi...

On Fri, Jun 22, 2012 at 11:27 PM, NorthPole <morfeas3000@gmail.com> wrote:
> Hi...
>
> The virtual machine is supposed to run on 128 mb ram and according to the
> batman folks its more than enough
>
> How can I force a backtrace?

When it hangs, AFAIK in gdb, press ctrl-c...it will get you back to
gdb prompt ... then type "bt" and Enter.

I assume you use gdb that is hooked into qemu's gdb stub, right?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

* geting weird semi-random panic on kmalloc
  2012-06-22 16:49     ` Mulyadi Santosa
@ 2012-06-25 23:22       ` NorthPole
  2012-06-26  4:31         ` Mulyadi Santosa
  0 siblings, 1 reply; 8+ messages in thread
From: NorthPole @ 2012-06-25 23:22 UTC (permalink / raw)
  To: kernelnewbies

@Mulyadi Santosa

several sources on the net suggested that interactive debuggers on the
kernel are a bad thing so I pushed it down on the todo kernel-skill stack
so I dont yet know how to use qemu's gdb with the kernel

Good news is I found the error (not me the folks at batman's irc channel
did)  the

memcpy(tvlv+sizeof(struct shortTvlv),value,length*sizeof(uint8_t)); needs
to be
memcpy((char *)tvlv+sizeof(struct shortTvlv),value,length*sizeof(uint8_t));

thanks for the assist everyone and if you have any good tutorials on qemu +
kernel +gdb i'll be thankfull


On Fri, Jun 22, 2012 at 7:49 PM, Mulyadi Santosa
<mulyadi.santosa@gmail.com>wrote:

> Hi...
>
> On Fri, Jun 22, 2012 at 11:27 PM, NorthPole <morfeas3000@gmail.com> wrote:
> > Hi...
> >
> > The virtual machine is supposed to run on 128 mb ram and according to the
> > batman folks its more than enough
> >
> > How can I force a backtrace?
>
> When it hangs, AFAIK in gdb, press ctrl-c...it will get you back to
> gdb prompt ... then type "bt" and Enter.
>
> I assume you use gdb that is hooked into qemu's gdb stub, right?
>
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120626/359d2089/attachment.html 

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

* geting weird semi-random panic on kmalloc
  2012-06-25 23:22       ` NorthPole
@ 2012-06-26  4:31         ` Mulyadi Santosa
  0 siblings, 0 replies; 8+ messages in thread
From: Mulyadi Santosa @ 2012-06-26  4:31 UTC (permalink / raw)
  To: kernelnewbies

Hi... :)

On Tue, Jun 26, 2012 at 6:22 AM, NorthPole <morfeas3000@gmail.com> wrote:
> @Mulyadi Santosa
>
> several sources on the net suggested that interactive debuggers on the
> kernel are a bad thing so I pushed it down on the todo kernel-skill stack so
> I dont yet know how to use qemu's gdb with the kernel

it is described in qemu wiki website actually. I found it here:
http://www.elinux.org/Virtual_Development_Board

jump into 'Debug U-Boot" section. Of course, adjust the parameters so
that it boots your kernel name and you invoke the qemu arch of your
choice. The rest is the same.

Other thing that I recall is sometimes Qemu had trouble when debugging
interrupts....or in general things that works periodically.

> Good news is I found the error (not me the folks at batman's irc channel
> did) ?the
>
> memcpy(tvlv+sizeof(struct shortTvlv),value,length*sizeof(uint8_t)); needs to
> be
> memcpy((char *)tvlv+sizeof(struct shortTvlv),value,length*sizeof(uint8_t));

great!! :) casting mistakes, right?

> thanks for the assist everyone and if you have any good tutorials on qemu +
> kernel +gdb i'll be thankfull
>

See above :) google might reveal more IMHO

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

end of thread, other threads:[~2012-06-26  4:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-22  0:50 geting weird semi-random panic on kmalloc NorthPole
2012-06-22 11:55 ` Jonathan Neuschäfer
2012-06-22 12:06   ` NorthPole
2012-06-22 16:18 ` Mulyadi Santosa
2012-06-22 16:27   ` NorthPole
2012-06-22 16:49     ` Mulyadi Santosa
2012-06-25 23:22       ` NorthPole
2012-06-26  4:31         ` Mulyadi Santosa

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).