Problem using libtiff in debug mode with visual studio 2010

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

Hello,


I am using libtiff with visual studio 2010. When I use it in the "Release" mode of visual studio, everything is working fine. But when I switch visual studio to "Debug" mode, I have the following popup error that comes when I call TIFFOpen:



it's written:

Debug assertion failed!

Program: C:\ProjetsEnCours\LastTryWithOpenCvInside\Debug\LastTry.exe

File: f:\dd\vctools\crt_bld\self_x86\crt\src\fstat64.c

Line 94


Expression: (_osfile(fildes) & FOPEN)


For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.


Has anyone already had the same error and know how the resolve it?

Thanks,

Emmanuel



_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Bob Friesenhahn
On Thu, 5 Oct 2017, Emmanuel Cosnard wrote:
>
> Expression: (_osfile(fildes) & FOPEN)
>
>
> For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
>
>
> Has anyone already had the same error and know how the resolve it?

We have not heard of this before but it seems likely that the problem
is due to attempting to close a file descriptor which is not currently
open (either never been opened, or already been closed).  This could
be due to a bug in libtiff or your application.

You are going to need to debug this for yourself some more such as
finding the call stack and arguments which lead to this situation.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

I've just noticed that the problem occures only when I try to open a Tif with custom tags.

But I still have no idea why it works in Release and not in debug...


De : Bob Friesenhahn <[hidden email]>
Envoyé : jeudi 5 octobre 2017 16:13:49
À : Emmanuel Cosnard
Cc : [hidden email]
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On Thu, 5 Oct 2017, Emmanuel Cosnard wrote:
>
> Expression: (_osfile(fildes) & FOPEN)
>
>
> For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
>
>
> Has anyone already had the same error and know how the resolve it?

We have not heard of this before but it seems likely that the problem
is due to attempting to close a file descriptor which is not currently
open (either never been opened, or already been closed).  This could
be due to a bug in libtiff or your application.

You are going to need to debug this for yourself some more such as
finding the call stack and arguments which lead to this situation.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

Actually the failure occures just after I get the warning on the console: "red.Tif: Error fetching data for field "Tag 1808."", which is the warning I get when I open a tif file with custom tags. It doesn't stop the code when I am in release, but it does when I am in debug mode. Do you think libtiff in this case returns an error that isn't supported by visual studio in debug and causes its failure? Could I change it by some sort of other warning?


De : Emmanuel Cosnard
Envoyé : vendredi 6 octobre 2017 08:24:45
À : Bob Friesenhahn
Cc : [hidden email]
Objet : RE: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 

I've just noticed that the problem occures only when I try to open a Tif with custom tags.

But I still have no idea why it works in Release and not in debug...


De : Bob Friesenhahn <[hidden email]>
Envoyé : jeudi 5 octobre 2017 16:13:49
À : Emmanuel Cosnard
Cc : [hidden email]
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On Thu, 5 Oct 2017, Emmanuel Cosnard wrote:
>
> Expression: (_osfile(fildes) & FOPEN)
>
>
> For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
>
>
> Has anyone already had the same error and know how the resolve it?

We have not heard of this before but it seems likely that the problem
is due to attempting to close a file descriptor which is not currently
open (either never been opened, or already been closed).  This could
be due to a bug in libtiff or your application.

You are going to need to debug this for yourself some more such as
finding the call stack and arguments which lead to this situation.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Olivier Paquet-2
In reply to this post by Emmanuel Cosnard
2017-10-06 4:24 GMT-04:00 Emmanuel Cosnard <[hidden email]>:
> But I still have no idea why it works in Release and not in debug...

It's an assertion within the C library and those are not present in
the release version. But the release C runtime probably still has code
to quietly ignore the error instead of crashing.
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Bob Friesenhahn
In reply to this post by Emmanuel Cosnard
On Fri, 6 Oct 2017, Emmanuel Cosnard wrote:

> I've just noticed that the problem occures only when I try to open a Tif with custom tags.
>
> But I still have no idea why it works in Release and not in debug...

The answer to that is simple.  The release mode build disables
assertion statements while the debug build enables them.

You have provided us with remarkably little information.  Helpful
information would include:

  * The libtiff version you are using.

  * Whether tif_win32.c or tif_unix.c is used for file I/O, or if you
   are providing your own I/O support.

  * A sample TIFF file which causes the problem.

  * A debugger backtrace for when the problem occurs.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Bob Friesenhahn
On Fri, 6 Oct 2017, Emmanuel Cosnard wrote:

> I am using libtiff version 3.8.2, with tif_win32.c.

This is a very antique version of libtiff, perhaps dating from 2006.
Are you able to update to modern libtiff?

The latest release is 4.0.8. See
http://www.simplesystems.org/libtiff/v4.0.8.html.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

Actually I can't use the last version of tifflib because I have to use visual studio 2010 (for historical reasons on the project I'm working on), so I  have to use a pre-2010 version of libtiff.


Emmanuel


De : Bob Friesenhahn <[hidden email]>
Envoyé : vendredi 6 octobre 2017 17:00:50
À : Emmanuel Cosnard
Cc : [hidden email]
Objet : RE: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On Fri, 6 Oct 2017, Emmanuel Cosnard wrote:

> I am using libtiff version 3.8.2, with tif_win32.c.

This is a very antique version of libtiff, perhaps dating from 2006.
Are you able to update to modern libtiff?

The latest release is 4.0.8. See
http://www.simplesystems.org/libtiff/v4.0.8.html.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

rleigh
On 09/10/2017 07:19, Emmanuel Cosnard wrote:
> Actually I can't use the last version of tifflib because I have to use
> visual studio 2010 (for historical reasons on the project I'm working
> on), so I  have to use a pre-2010 version of libtiff.

What's stopping libtiff 4.0.8 building on these Visual Studio versions?
What errors do you get when building?

Have you tried the CMake build out?  Bits in the port directory should
be selectively built to work with older versions.  While I don't have
these older versions to hand to test with, I think they are supposed to
work.


Regards,
Roger
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

I am getting all these errors with the last version of libtiff:


Erreur    LNK2001    unresolved external symbol __imp____acrt_iob_func    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_unix.obj)    1    
Erreur    LNK1120    11 unresolved externals    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\Debug\LastTry.exe    1    
Erreur    LNK2001    unresolved external symbol __libm_sse2_sqrt_precise    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_luv.obj)    1    
Erreur    LNK2001    unresolved external symbol __libm_sse2_log_precise    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_luv.obj)    1    
Erreur    LNK2001    unresolved external symbol __libm_sse2_exp_precise    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_luv.obj)    1    
Erreur    LNK2001    unresolved external symbol __dtoui3    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirwrite.obj)    1    
Erreur    LNK2001    unresolved external symbol __ftoui3    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirwrite.obj)    1    
Erreur    LNK2001    unresolved external symbol __ultod3    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirread.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vsprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_codec.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vsprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirinfo.obj)    1    
Erreur    LNK2001    unresolved external symbol __ltod3    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirread.obj)    1    
Erreur    LNK2001    unresolved external symbol __ltod3    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_aux.obj)    1    
Erreur    LNK2001    unresolved external symbol __libm_sse2_pow_precise    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_aux.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vfprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_predict.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vfprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_fax3.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vfprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_dirinfo.obj)    1    
Erreur    LNK2001    unresolved external symbol __imp____stdio_common_vfprintf    LastTry    C:\ProjetsEnCours\LastTryWithLibtiff408\LastTry\libtiff.lib(tif_unix.obj)    1


De : [hidden email] <[hidden email]> de la part de Roger Leigh <[hidden email]>
Envoyé : lundi 9 octobre 2017 07:41:40
À : [hidden email]
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On 09/10/2017 07:19, Emmanuel Cosnard wrote:
> Actually I can't use the last version of tifflib because I have to use
> visual studio 2010 (for historical reasons on the project I'm working
> on), so I  have to use a pre-2010 version of libtiff.

What's stopping libtiff 4.0.8 building on these Visual Studio versions?
What errors do you get when building?

Have you tried the CMake build out?  Bits in the port directory should
be selectively built to work with older versions.  While I don't have
these older versions to hand to test with, I think they are supposed to
work.


Regards,
Roger
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Bob Friesenhahn
On Mon, 9 Oct 2017, Emmanuel Cosnard wrote:

> I am getting all these errors with the last version of libtiff:

It looks to me like these issues have something to do with a mis-match
between how libtiff was compiled and how the using application is
being compiled.  The compilation options need to be compatible.

In GraphicsMagick I am still using Visual Studio 2008 to compile
modern libtiff and would expect it to compile even under the 2003
version.  In fact, I think that it might even compile under Visual C++
6.0.  Visual Studio 2015 also compiled libtiff with no problems.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

The right way to compile libtiff is to go on the libtiff directory download and execute the following command line, right?

nmake /f makefile.vc
Is there anything else to do? Because I've been checking everything and I don't know why the last version can't work with my programm.


De : Bob Friesenhahn <[hidden email]>
Envoyé : lundi 9 octobre 2017 13:39:35
À : Emmanuel Cosnard
Cc : Roger Leigh; [hidden email]
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On Mon, 9 Oct 2017, Emmanuel Cosnard wrote:

> I am getting all these errors with the last version of libtiff:

It looks to me like these issues have something to do with a mis-match
between how libtiff was compiled and how the using application is
being compiled.  The compilation options need to be compatible.

In GraphicsMagick I am still using Visual Studio 2008 to compile
modern libtiff and would expect it to compile even under the 2003
version.  In fact, I think that it might even compile under Visual C++
6.0.  Visual Studio 2015 also compiled libtiff with no problems.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

I finally managed to build and install the latesr version of libtiff on visual studio 2010, but I still have exactly the same mistake in debug when I do a TIFFopen in debug mode.


What I did to build libtiff is to use the command prompt of visual studio 2010, and executed the following command lines in the libtiff directory:

nmake /f makefile.vc clean
nmake /f makefile.vc DEBUG=1
Do you know if there is something I am doing wrong here?

Thank you,

Emmanuel


De : Bob Friesenhahn <[hidden email]>
Envoyé : lundi 9 octobre 2017 13:39:35
À : Emmanuel Cosnard
Cc : Roger Leigh; [hidden email]
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 
On Mon, 9 Oct 2017, Emmanuel Cosnard wrote:

> I am getting all these errors with the last version of libtiff:

It looks to me like these issues have something to do with a mis-match
between how libtiff was compiled and how the using application is
being compiled.  The compilation options need to be compatible.

In GraphicsMagick I am still using Visual Studio 2008 to compile
modern libtiff and would expect it to compile even under the 2003
version.  In fact, I think that it might even compile under Visual C++
6.0.  Visual Studio 2015 also compiled libtiff with no problems.

Bob
--
Bob Friesenhahn
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Even Rouault-2

On mardi 10 octobre 2017 12:07:49 CEST Emmanuel Cosnard wrote:

> I finally managed to build and install the latesr version of libtiff on

> visual studio 2010, but I still have exactly the same mistake in debug when

> I do a TIFFopen in debug mode.

>

>

> What I did to build libtiff is to use the command prompt of visual studio

> 2010, and executed the following command lines in the libtiff directory:

>

> nmake /f makefile.vc clean

>

> nmake /f makefile.vc DEBUG=1

>

> Do you know if there is something I am doing wrong here?

 

I don't see anything in nmake.opt that would react on a DEBUG=1 option

 

But you probably need to replace

 

OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE

 

by

 

OPTFLAGS = /MDd /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE

 

The critical change is /MD to /MDd to use the debug C runtime.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Emmanuel Cosnard

Thank you very much Even, it's working perfect now! But it's not working anymore in release... Is there a way to make it work for both, or should I duplicate them, i.e one for debug and one for release?


De : Even Rouault <[hidden email]>
Envoyé : mardi 10 octobre 2017 12:22:16
À : [hidden email]
Cc : Emmanuel Cosnard; Bob Friesenhahn
Objet : Re: [Tiff] Problem using libtiff in debug mode with visual studio 2010
 

On mardi 10 octobre 2017 12:07:49 CEST Emmanuel Cosnard wrote:

> I finally managed to build and install the latesr version of libtiff on

> visual studio 2010, but I still have exactly the same mistake in debug when

> I do a TIFFopen in debug mode.

>

>

> What I did to build libtiff is to use the command prompt of visual studio

> 2010, and executed the following command lines in the libtiff directory:

>

> nmake /f makefile.vc clean

>

> nmake /f makefile.vc DEBUG=1

>

> Do you know if there is something I am doing wrong here?

 

I don't see anything in nmake.opt that would react on a DEBUG=1 option

 

But you probably need to replace

 

OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE

 

by

 

OPTFLAGS = /MDd /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE

 

The critical change is /MD to /MDd to use the debug C runtime.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

Even Rouault-2

On mardi 10 octobre 2017 14:28:12 CEST Emmanuel Cosnard wrote:

> Thank you very much Even, it's working perfect now! But it's not working

> anymore in release... Is there a way to make it work for both, or should I

> duplicate them, i.e one for debug and one for release?

>

 

Yes you need to change the OPTFLAGS according to the build type you do.

 

By the way, in CVS, I've just added a DEBUG option as you tried so as to adjust OPTFLAGS depending if it is present or not

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Problem using libtiff in debug mode with visual studio 2010

rleigh
In reply to this post by Emmanuel Cosnard
On 10/10/2017 14:28, Emmanuel Cosnard wrote:
> Thank you very much Even, it's working perfect now! But it's not working
> anymore in release... Is there a way to make it work for both, or should
> I duplicate them, i.e one for debug and one for release?

Another approach is to use the CMake build:

mkdir build
cd build
cmake -G "Visual Studio 10 2010 [Win64]" \path\to\libtiff
cmake --build . -C Debug
cmake --build . -C Release
[ or build in Visual Studio or run msbuild yourself ]

Or

cmake -DCMAKE_BUILD_TYPE=(Debug|Release) \path\to\libtiff
nmake

CMake supports multiple build systems, these are two possibilities which
will work using msbuild or nmake.  Debug and Release build options are
set automatically with both generators, and you can add your own options
as needed.


Regards,
Roger
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/