Bug 71113

Summary: longstanding bug in /usr/include/expect.h
Product: [Retired] Red Hat Linux Reporter: Need Real Name <yarnall>
Component: tcltkAssignee: Jens Petersen <petersen>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-08-12 12:56:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2002-08-08 21:13:53 UTC
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 10:40:32 UTC
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 12:39:18 UTC
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 12:56:12 UTC
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 06:25:52 UTC
Thanks for the report.  I updated expect to 5.38.0.