Skip to content

GitLab

    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    • Menu
    Projects Groups Snippets
  • Get a free trial
  • Sign up
  • Login
  • Sign in / Register
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1,261
    • Issues 1,261
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 46
    • Merge requests 46
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPC
  • FPC SourceFPC Source
  • Issues
  • #16801
Closed
Open
Created Jun 27, 2010 by FPC Admin account@fpc_adminOwner

loading FPC dll messes with host app's floating-point exception flags

Original Reporter info from Mantis: grant8
  • Reporter name: Grant Allan

Description:

My host app is written in fortran. I am loading the DLL at runtime using LoadLibrary. Before the LoadLibrary call, my 8087 control word is $33F. After the LoadLibrary call, the control word is $332.

I feel very lucky that I managed to narrow it down to this - if I was not using the LoadLibrary method of loading the DLL, I may never have found it. This might cost some other programmer many hours of frustration.

I have added fortran code to query the control word before LoadLibrary, and then restore it afterwards. It seems to work OK for the debug build of my fortran application. But for the release build of my fortran app I end up with heap corruption message from windows; it tells me that I have a bug in either my host application or one of the DLLs it has loaded.

Steps to reproduce:

  1. write an application in fortran, using compiler setting to generate NaNs instead of throwing floating point exceptions
  2. write a DLL with lazarus
  3. in the fortran, add a call LoadLibrary, and code to query the 8087 control word before and after the call.

Additional information:

The lazarus DLL and the fortran exe are both 64-bit. So I'm not really sure how legitimate it is for me to be messing with the 8087 control word at all, because I have read that doing so is IA32-specific??? So, even though un-blatting the control word seemed to fix the problem for my debug build of the Fortran exe, maybe that was just lucky?

Mantis conversion info:

  • Mantis ID: 16801
  • OS: Windows
  • OS Build: 7
  • Build: Lazarus 0.9.28.2 beta, svn 22279
  • Platform: EM64T / AMD64
  • Version: 2.2.4
  • Fixed in version: 2.6.0
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking