[if gte mso 9]>

Re: [edk2] ASSERT Divisor != 0 Ia32

Subject: Re: [edk2] ASSERT Divisor != 0 Ia32

From: Evan Lloyd <Evan.Lloyd@arm.com>

To: "edk2-devel@lists.sourceforge.net" <edk2-devel@lists.sourceforge.net>

Date: 2012-01-06 17:36:41

You do not give the actual code of your macros, but I’d suggest trying:

#define macro1(a,b) ((a) / (b))
#define macro2(a,b) ((a) % (b))
which will at least eliminate one possible cause.

 

Regards,

Evan

 

From: void f [mailto:void@fsck.ro]
Sent: 05 January 2012 22:36
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] ASSERT Divisor != 0 Ia32

 

Hello,

I wrote a device driver for edk2 which was tested using Ovmf on an X64 system.

Now for $insert_random_reason I switched to a 32 bit system and I began to receive errors due to missing __udivdi3 and __umoddi3. Went ahead and copied udivdi3.S/umoddi3.S from StdLib/LibC/CRT/Ia32 along with Gcc.c from StdLib/LibC/CRT and added Gcc.c | GCC to my .inf file.

Everything is fine and dandy except that I get

__udivdi3: 1 0 //somewhere there is a call to udivdi3 with arguments 1 and 0
ASSERT ...tianocore/edk2/MdePkg/Library/BaseLib/DivU64x64Remainder.c(47): Divisor != 0

There are 3 uses of division in my project in two macros. Let's say

#define macro1(a,b) (a) / (b)
#define macro2(a,b) (a) % (b)

Using DEBUG((EFI_D_INFO ...)) since I couldn't find any other way of debugging on Ovmf (if there's a better way please point me in the right direction) I tracked down a section of code after which no other messages are displayed.

OldTpl = gBS->RaiseTPL (TPL_CALLBACK); //with or without same result
macro1(a,b) // fine
macro2(a,b) // fine
DEBUG((mesage1))
func(macro1(a,b), macro2(a,b))
DEBUG((mesage2)) //not displayed instead the ASSERT kicks in
gBS->RestoreTPL (OldTpl);

If I go into func and place a DEBUG message as the first thing to do after being call it is not displayed. So this is really puzzling to me.

Is there a chance that a call to func can divide by 0? Am I misusing udivdi3.S/umoddi3.S? Any way that I can get a backtrace from __udivdi3?

Regards


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.