Re: VC++ 2005 beta1 fails with pthreads benchmark tests




"um" <dont_email@xxxxxxxxxx> wrote in message
news:e47hxPORFHA.3628@xxxxxxxxxxxxxxxxxxxxxxx
> "David Schwartz" wrote
>>
>> "um" wrote
>>
>> > if ( result == -1 )
>> > {
>> > perror("thread: sem_trywait 1: expected error"); // No error
>> > assert(errno == EAGAIN);
>> >
>> > It is the last assert which fails in the first of the failing test
>> > programs.
>>
>> Why should 'perror' be expected to cause an 'EGAIN' error? You need
>> to
>> test 'errno' before calling any library functions that might change its
>> value. This code is broken.
>
> The code is not broken.

It is.

> In your quote you have left out the
> relevant part of the code.
> It is not perror which sets errno (funny imagination, btw).

How do you know that?

> errno is set by sem_trywait(). The code is:

yes, it's set by 'sem_trywait', but then the code calls 'perror' before
checking it!

> assert((result = sem_trywait(&s)) == -1);
> if ( result == -1 )
> {
> perror("thread: sem_trywait 1: expected error"); // No error
> assert(errno == EAGAIN);

Again, why would you expect 'perror' to set errno to 'EAGAIN'? Do you
have some documentation that says 'perror' is guaranteed not to change
errno?

DS


.



Relevant Pages

  • Re: VC++ 2005 beta1 fails with pthreads benchmark tests
    ... >> It is not perror which sets errno ... I hope it helps the developers at MS to fix the product. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: VC++ 2005 beta1 fails with pthreads benchmark tests
    ... >> It is the last assert which fails in the first of the failing test ... It is not perror which sets errno ...
    (microsoft.public.dotnet.languages.vc)
  • Re: perror sets errno to "Illegal Seek"
    ... > I have the most recent glibc, and it doesn't seem to do that.. ... > While another thread is running, that sets errno to a certain value, I ... errno and perror are the right way. ...
    (comp.os.linux.development.apps)
  • Re: When to use "perror" and "fprintf"
    ... >> range and set errno to ERANGE. ... the error message output by perror ... If they're identical, display only one, otherwise display ... Dan Pop ...
    (comp.lang.c)
  • Re: perror sets errno to "Illegal Seek"
    ... Calling perror() again may print out anything, ... you call a library function you can't depend on errno not being touched. ... *if* the function reports failure *and* the specification says the function ... not ESUCCESS otherwise". ...
    (comp.os.linux.development.apps)