Bug 71113 - longstanding bug in /usr/include/expect.h
longstanding bug in /usr/include/expect.h
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: tcltk (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jens Petersen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-08-08 17:13 EDT by Need Real Name
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-08-12 08:56:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-08-08 17:13:53 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Description of problem:
the extern global exp_readenv is not marked EXTERN in expect.h.  Trying to link
against libexpect results in multiple definition link errors.  

This has been true for several generations of RHL.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.  Write a program that includes /usr/lib/expect.h and links with -lexpect.
2.  Compile that program, and try to link it.  
3.  Poof!
	

Actual Results:  link errors

Expected Results:  no link errors...

Additional info:
Comment 1 Jens Petersen 2002-08-12 06:40:32 EDT
Could you give an explicit example how to reproduce this?

The following working for me:

% mkdir tmp; cd tmp
% cat > main.c <<EOF
#include <expect.h>

int
main (int argc, char *argv[])
{
  return 0;
}
EOF
% gcc -lexpect main.c
% ./a.out
%
Comment 2 Need Real Name 2002-08-12 08:39:18 EDT
Sorry;  I should have been more explicit...

You need a project that includes <expect.h> in multiple files to produce
multiple definitions.  Also, I just did an experiment, and the C++ compiler
seems to mind, whereas the C compiler doesn't.  Try this instead:

-----------------------------------------
(file1.cpp)

#include <iostream>
#include <expect.h>

using namespace std;

int foo();

int main()
{
    cout << foo() << endl;
}


---------------------------------------------------
(file2.cpp)

#include <expect.h>

int foo() 
{
    return 42;
}

-----------------------------------------------------
% g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110)

% g++ -o exp file1.cpp file2.cpp -lexpect
/tmp/ccs329IM.o(.bss+0x0): multiple definition of `exp_readenv'
/tmp/ccNqm4kO.o(.bss+0x0): first defined here
collect2: ld returned 1 exit status
Comment 3 Need Real Name 2002-08-12 08:56:12 EDT
A followup:  I found more recent versions of expect at the homepage
(expect.nist.gov), which contains the same fix I use:  

% diff -c expect.h expect.new
*** expect.h	Thu Feb 28 16:16:08 2002
--- expect.new	Thu Aug  8 16:48:40 2002
***************
*** 427,435 ****
  EXTERN int exp_console;			/* redirect console */
  
  #ifdef HAVE_SIGLONGJMP
! sigjmp_buf exp_readenv;		/* for interruptable read() */
  #else
! jmp_buf exp_readenv;		/* for interruptable read() */
  #endif /* HAVE_SIGLONGJMP */
  
  EXTERN int exp_reading;			/* whether we can longjmp or not */
--- 427,435 ----
  EXTERN int exp_console;			/* redirect console */
  
  #ifdef HAVE_SIGLONGJMP
! EXTERN sigjmp_buf exp_readenv;		/* for interruptable read() */
  #else
! EXTERN jmp_buf exp_readenv;		/* for interruptable read() */
  #endif /* HAVE_SIGLONGJMP */
  
  EXTERN int exp_reading;			/* whether we can longjmp or not */
Comment 4 Jens Petersen 2002-08-13 02:25:52 EDT
Thanks for the report.  I updated expect to 5.38.0.

Note You need to log in before you can comment on or make changes to this bug.