in

Support Portal

Floating Point Exception

Last post 08-20-2007 11:12 AM by Ben Hejl. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-09-2007 2:08 PM

    • chunkyd
    • Top 25 Contributor
    • Joined on 08-09-2007
    • Patch Code
    • Points 16

    Floating Point Exception

    Hello,

    I am writing a DLL that takes an image and calls the SD library to decode the barcodes in the image.  After calling SD_Decode() I frequently get a floating point exception.

    After reading the user guide I noticed that one of the release notes mentions that the SD library could cause floating point exceptions and that they should be masked by the user.  The release notes also mentions that this will be fixed in future releases and though this note is quite some versions ago none of the other release notes mentions a fix.

    Basically, my question is if the floating point exceptions are expected or are a bug I am encountering?


     

    Filed under: ,
    • Post Points: 4
  • 08-09-2007 3:01 PM In reply to

    • Ben Hejl
    • Top 10 Contributor
    • Joined on 05-11-2007
    • Cherry Hill, New Jersey
    • UPC
    • Points 95

    Re: Floating Point Exception

    You should not receive floating point exceptions.  Can you send an image that causes the problem as well as the settings you are using (symbologies enabled, misc properties, etc.)?

    • Post Points: 4
  • 08-09-2007 3:20 PM In reply to

    • chunkyd
    • Top 25 Contributor
    • Joined on 08-09-2007
    • Patch Code
    • Points 16

    Re: Floating Point Exception

    I am using the 2DSymbols.bmp sample image that comes with the software.  But it does not seem to matter which image I use and does not occur every time I attempt to decode the image.

    I have these symbologies enabled:
    QR and microQR (normal and inverse)
    MaxiCode
    Aztec
    PDF417
    DataMatrix (normal and inverse)

    I only use the RESULT callback and do not set the PROGRESS callback.

    Here is how I call SD_Decode:

    SD_Set( handle, SD_PROP_IMAGE_HEIGHT, (void*)height );
    SD_Set( handle, SD_PROP_IMAGE_WIDTH, (void*)width );
    SD_Set( handle, SD_PROP_IMAGE_LINE_DELTA, (void*)width );
    SD_Set( handle, SD_PROP_IMAGE_POINTER, (void*)imagePtr );
    SD_Decode( handle );

    • Post Points: 4
  • 08-09-2007 3:29 PM In reply to

    Re: Floating Point Exception

    Can you attach a .c file that contains a simple program that causes a floating point exception? This will allow us to figure out what is going on in your code.

    • Post Points: 4
  • 08-09-2007 5:00 PM In reply to

    • chunkyd
    • Top 25 Contributor
    • Joined on 08-09-2007
    • Patch Code
    • Points 16

    Re: Floating Point Exception

    So the dll I am writing is actually a mexFunction for Matlab.  Has anyone done that before?  Are there any known issues with trying to do that?

    MexFunctions are basically just DLLs that have a particular method exposed which Matlab calls and passes data to and receives data from.

    • Post Points: 4
  • 08-09-2007 5:28 PM In reply to

    Re: Floating Point Exception

    To the best of my knowledge, none of our customers have called SwiftDecoder from Matlab using a mexFunction. But looking at some descriptions of the mexFunction, it looks like it should work. Because SwiftDecoder was supplied to you as a DLL, did you include the #define SD_API2_IS_DLL macro definition in your source prior to including the sd.h header file? If this macro is missing, this will cause incorrect function linkage conventions to be used between your mexFunction and the SwiftDecoder DLL. This can cause all sorts of problems. Please refer to the SwiftDecoder documentation for further details.

    If you did include the macro, if you could send us the source for a very simple mexFunction function that exhibits the floating point exception, this will help us understand what you are trying to do.

    • Post Points: 4
  • 08-09-2007 10:26 PM In reply to

    • chunkyd
    • Top 25 Contributor
    • Joined on 08-09-2007
    • Patch Code
    • Points 16

    Re: Floating Point Exception

    Yes, I did include the #define as you mentioned.  Also, I did a little more testing to try and uncover the source of the problem.

    First, I copied my code to a console app (instead of building a DLL).  The code ran fine.  Second I created another console app that loads the mexFunction DLL and calls the exported function in the DLL.  That worked as well.  So it seems that the issue must be with the environment in which Matlab loads and executes the DLL.

    • Post Points: 4
  • 08-20-2007 11:12 AM In reply to

    • Ben Hejl
    • Top 10 Contributor
    • Joined on 05-11-2007
    • Cherry Hill, New Jersey
    • UPC
    • Points 95

    Re: Floating Point Exception

    The problem is caused because SwiftDecoder will typically modify the floating point exception mask when SD_Decode is called.  The floating point exception mask will be set back to its original value before a call to SD_Decode, but this may cause problems during callback functions.  This is an issue that exists in previous versions of Matlab.  For more information: http://www.mathworks.com/support/bugreports/details.html?rp=350200.

    • Post Points: 1
Page 1 of 1 (8 items)
Copyright Omniplanar, Inc. 2007
Powered by Community Server (Commercial Edition), by Telligent Systems