Skip to contentSkip to conversation

return hidden bug

PATCH In review Roel Kluin 7 participants 16 messages Oct 22, 2007 – Oct 23, 2007 Alpha port

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 return hidden bug

return hidden bug

arch/alpha/kernel/pci_iommu.c +1 -1
index e1c4707..6a69425 100644
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
 		printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
 		       " base %lx size %x\n", dma_addr, arena->dma_base,
 		       arena->size);
-		return;
 		BUG();
+		return;
 	}
 
 	npages = calc_npages((dma_addr & ~PAGE_MASK) + size);
#1 lore raw
Quoted 11 lines · On Mon, 22 Oct 2007 03:05:05 +0200 Roel Kluin <[email protected]> wrote:

return hidden bug

(quoted diff) +0 -0

b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644

arch/alpha/kernel/pci_iommu.c +0 -0
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t

dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single:
dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base,

arch/alpha/kernel/pci_iommu.c pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, · line 372

Quoted 7 lines
arch/alpha/kernel/pci_iommu.c +1 -1
 		       arena->size);
-		return;
 		BUG();
+		return;
 	}
 
 	npages = calc_npages((dma_addr & ~PAGE_MASK) + size);

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
author
#2 lore raw
Quoted 20 lines · Rik van Riel
Quoted 17 lines · On Mon, 22 Oct 2007 03:05:05 +0200 Roel Kluin <[email protected]> wrote:

return hidden bug

(quoted diff) +0 -0

b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644

arch/alpha/kernel/pci_iommu.c +0 -0
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t

dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single:
dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base,

arch/alpha/kernel/pci_iommu.c +1 -1
 		       arena->size);
-		return;
 		BUG();
+		return;
 	}
Quoted 6 lines
Quoted 1 line

npages = calc_npages((dma_addr & ~PAGE_MASK) + size);

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

---
hidden bug returns

---

arch/alpha/kernel/pci_iommu.c +0 -1
index e1c4707..ca55c33 100644
@@ -365,7 +365,6 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size,
 		printk(KERN_ERR "Bogus pci_unmap_single: dma_addr %lx "
 		       " base %lx size %x\n", dma_addr, arena->dma_base,
 		       arena->size);
-		return;
 		BUG();
 	}
 
#4 lore raw
In reply to Rik van Riel
Quoted 4 lines · Rik van Riel

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

This is true in general. However, if someone builds the kernel with CONFIG_BUG disabled then the return statement will make a difference. Of course, if you're brave enough to have CONFIG_BUG off then you can deal with the fall-out :)

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw
In reply to Rik van Riel

Hi,

Quoted 3 lines · Rik van Riel

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

This isn't true when CONFIG_BUG is disabled (in embedded builds, for example).

Pekka

#6 lore raw
Quoted 7 lines · On Mon, 22 Oct 2007 12:30:00 +0300 "Pekka Enberg" <[email protected]>…
Quoted 3 lines · Rik van Riel

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

This isn't true when CONFIG_BUG is disabled (in embedded builds, for example).

*blink*

I guess people who disable CONFIG_BUG really choose to shoot themselves in the foot when something bad happens. The kernel is full of error paths where the current thread really should not be continuing.

Oh well...

Signature · 3 lines
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
#7 lore raw

Hi Rik,

Quoted 4 lines · Rik van Riel

On Mon, 22 Oct 2007 12:30:00 +0300
I guess people who disable CONFIG_BUG really choose to shoot themselves in the foot when something bad happens. The kernel is full of error paths where the current thread really should not be continuing.

Sure, if you disable BUG_ON, it may or may not work. But making it *worse* on purpose seems pointless.

#8 lore raw
In reply to Rik van Riel
Quoted 20 lines · Rik van Riel
Quoted 17 lines · On Mon, 22 Oct 2007 03:05:05 +0200 Roel Kluin <[email protected]> wrote:

return hidden bug

(quoted diff) +0 -0

b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644

arch/alpha/kernel/pci_iommu.c +0 -0
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t

dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single:
dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base,

                     arena->size);
arch/alpha/kernel/pci_iommu.c +1 -1
-             return;
              BUG();
+             return;
      }
Quoted 5 lines
Quoted 1 line
      npages = calc_npages((dma_addr & ~PAGE_MASK) + size);

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

I'm sorry, perhaps I poured myself a cup of stupid this morning, but isn't the above patch effectively introducing a BUG where none could be reached before? In other words, for the patch to have zero behavioral change, wouldn't it have to remove the BUG() altogether?

Ray

author
#9 lore raw
Quoted 4 lines · Ray Lee

I'm sorry, perhaps I poured myself a cup of stupid this morning, but isn't the above patch effectively introducing a BUG where none could be reached before? In other words, for the patch to have zero behavioral change, wouldn't it have to remove the BUG() altogether?

True, but obviously not intended. I think the intention was to expose this bug.

#10 lore raw
Quoted 8 lines · Roel Kluin
Quoted 4 lines · Ray Lee

I'm sorry, perhaps I poured myself a cup of stupid this morning, but isn't the above patch effectively introducing a BUG where none could be reached before? In other words, for the patch to have zero behavioral change, wouldn't it have to remove the BUG() altogether?

True, but obviously not intended. I think the intention was to expose this bug.

Arguing intentions is very dangerous. I've written code like that where the intention is to make it simple to turn a printk into a full bug and back and forth during development. At the end of the day, the fact remains that you're changing behavior.

Let me turn this around. Do you have an alpha and have you tried out your patch? If not, then I'd suggest turning it into a WARN_ON(1) instead, as in this specific case you're risking turning what was a working system into one that doesn't.

author
#11 lore raw
Quoted 11 lines · Ray Lee
Quoted 5 lines
Quoted 4 lines

I'm sorry, perhaps I poured myself a cup of stupid this morning, but isn't the above patch effectively introducing a BUG where none could be reached before? In other words, for the patch to have zero behavioral change, wouldn't it have to remove the BUG() altogether?

True, but obviously not intended. I think the intention was to expose this bug.

Arguing intentions is very dangerous. I've written code like that where the intention is to make it simple to turn a printk into a full bug and back and forth during development. At the end of the day, the fact remains that you're changing behavior.

Quoted 4 lines

Let me turn this around. Do you have an alpha and have you tried out your patch? If not, then I'd suggest turning it into a WARN_ON(1) instead, as in this specific case you're risking turning what was a working system into one that doesn't.

No, I haven't and, I will change it, but it's included with my other changes. see the reply that I'll write shortly for. [PATCH retry] return hidden bug and unlock bugs.

Roel

#12 lore raw
Quoted 7 lines · Roel Kluin
Quoted 5 lines · Ray Lee

Arguing intentions is very dangerous. I've written code like that where the intention is to make it simple to turn a printk into a full bug and back and forth during development. At the end of the day, the fact remains that you're changing behavior.

Quoted 8 lines
Quoted 4 lines

Let me turn this around. Do you have an alpha and have you tried out your patch? If not, then I'd suggest turning it into a WARN_ON(1) instead, as in this specific case you're risking turning what was a working system into one that doesn't.

No, I haven't and, I will change it, but it's included with my other changes. see the reply that I'll write shortly for. [PATCH retry] return hidden bug and unlock bugs.

Hugely trust inspiring isn't it -- the amount of eyes and comments you'll get even on trivial patches like this? This development model is working!

Now if only we'd sometimes get some for non trivial patches as well...

Rene.

#13 lore raw
Quoted 2 lines · Rene Herman

Hugely trust inspiring isn't it -- the amount of eyes and comments you'll get even on trivial patches like this? This development model is working!

Go easy with the snarkiness, hmm? It's the trivial ones that seem to be the most dangerous. The larger ones actually get *tested* sometimes.

Quoted 1 line

Now if only we'd sometimes get some for non trivial patches as well...

That's certainly true regardless, but for myself, I'd rather throw some reviews out for the small ones since I have adequate time and knowledge for them. The larger ones require domain specific knowledge I lack, and time I don't have.

~r.

#14 lore raw
Quoted 8 lines · Ray Lee
Quoted 2 lines · Rene Herman

Hugely trust inspiring isn't it -- the amount of eyes and comments you'll get even on trivial patches like this? This development model is working!

Go easy with the snarkiness, hmm? It's the trivial ones that seem to be the most dangerous. The larger ones actually get *tested* sometimes.

I was also commenting and don't generally on anything much more involved so any snarkiness included myself which should make things better.

Quoted 6 lines
Quoted 1 line

Now if only we'd sometimes get some for non trivial patches as well...

That's certainly true regardless, but for myself, I'd rather throw some reviews out for the small ones since I have adequate time and knowledge for them. The larger ones require domain specific knowledge I lack, and time I don't have.

Exactly the problem. Comment was mostly triggered due to me looking at a problem with a proprietary CD-ROM driver again tonight that I posted a few months ago where the only comment has been from the fellow author. There the problem was the block layer blowing up and given that it seems unlikely that this wouldn't be a problem inside the newbie-driver itself, that the block part of it was actually really small and people said they'd look at it, the subsequent thundering silence still annoys me.

Ofcourse, now it seems the kernel itself has moved on enough that the driver doesn't work at _all_ anymore and I at the moment lack the time to spend the required hours googling around trying to find out what the heck changed out from under me so that I might get it to at least do what it already did do.

Hey, I don't actually know and maybe I'm just wrong but I have the feeling that over the last 1 or 2 years most new developers seem to be either people that are payed to be so, perhaps in the form of graduation, or janitors. The kernel is much, much more complex than even only a few years ago and at the same time the number of knowledgeable developers who'll do something other than their own thing and otherwise just wait around for something perfect to merge seems to be approaching zero.

That is -- I do not feel that the current developer base is expending overly many efforts to appear welcoming.

Please feel free to do the open-source thing and argue that's actually an advantage (there we have that snarkiness again...) or otherwise ignore me. I'll just sit here and be grumpy anyway. Might be better after a good night's sleep...

Rene.

#15 lore raw
In reply to Rik van Riel
Quoted 20 lines · Rik van Riel
Quoted 17 lines · On Mon, 22 Oct 2007 03:05:05 +0200 Roel Kluin <[email protected]> wrote:

return hidden bug

(quoted diff) +0 -0

b/arch/alpha/kernel/pci_iommu.c index e1c4707..6a69425 100644

arch/alpha/kernel/pci_iommu.c +0 -0
@@ -365,8 +365,8 @@ pci_unmap_single(struct pci_dev *pdev, dma_addr_t

dma_addr, size_t size, printk(KERN_ERR "Bogus pci_unmap_single:
dma_addr %lx " " base %lx size %x\n", dma_addr, arena->dma_base,

arch/alpha/kernel/pci_iommu.c +1 -1
 		       arena->size);
-		return;
 		BUG();
+		return;
 	}
Quoted 5 lines
Quoted 1 line

npages = calc_npages((dma_addr & ~PAGE_MASK) + size);

BUG() will terminate the process that runs into it, so you can just remove the return alltogether. If BUG() is hit, the return will never be reached.

Looking at the printk, I don't think this particular error ought to forcefully kill things.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.