[ug-bosug] porting libntp .. AC_FUNC_MALLOC error

2007-08-10 Thread S h i v
On 8/9/07, S h i v shivakumar.gn at gmail.com wrote:
 (if it doesn't it is a bug against the compiler !)

A correction to my earlier post,
if it doesn't, technically is a bug against the library that
implements malloc. Such scenarios are often filed against the compiler
since most times the compiler ship with associate libs.

-Shiv



[ug-bosug] porting libntp .. AC_FUNC_MALLOC error

2007-08-10 Thread Jerry Raj


On 09/08/07 11:34, Anil Gulecha wrote:
 Hi all,
 
 I was trying to port libntp library that allows talking to
 Creative(and other) mp3 players.. the source consists of the libraries
 and a sample application.
 
 I had the initial -Wall errors that I corrected and the library has
 built fine. However, the sample app isnt building.
 
 bash-3.00$ pwd
 /tmp/libnjb-2.2.5
 bash-3.00$ ls src/.libs/
 base.o   ioutil.olibnjb.sonjbtime.oprotocol3.o
 byteorder.o  libnjb.alibnjb.so.5  playlist.o   songid.o
 datafile.o   libnjb.la   libnjb.so.5.1.0  procedure.o  unicode.o
 eax.olibnjb.lai  njb_error.o  protocol.o   usb_io.o
 bash-3.00$ cd sample/
 bash-3.00$ make
 /bin/bash ../libtool --tag=CC --mode=link /opt/SUNWspro/bin/cc
 -I../src -g  -L/usr/sfw/lib -o cursesplay  cursesplay.o
 ../src/libnjb.la -lcurses -lusb
 /opt/SUNWspro/bin/cc -I../src -g -o .libs/cursesplay cursesplay.o
 -L/usr/sfw/lib ../src/.libs/libnjb.so -lcurses -lusb -R/usr/local/lib
 Undefined   first referenced
  symbol in file
 rpl_malloc  ../src/.libs/libnjb.so
 ld: fatal: Symbol referencing errors. No output written to .libs/cursesplay
 make: *** [cursesplay] Error 1
 bash-3.00$
 
 
 Upon googling I found out about AC_FUNC_MALLOC macro in configure.ac
 that checks for correct calling of malloc, and malloc is replaced by
 rpl_malloc for incorrect calling.
 
 Workarounds are given at http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC
 
 but these appear to be more hacky that a correct workaround. According
 to http://cygwin.com/ml/automake/2003-05/msg00043.html that error
 comes forward when malloc isn't correctly called.. and thus the
 correct thing to do in this situation is patch the source by clearing
 this error.
 
 My questions are:
 
 What is the ideal way to patch this error?
 What is the best way to patch this error for a spec file?
 I removed the -Wall flag from the Makefiles.. however this was said to
 be hacky, What is the correct way of going about correcting this
 error?

This error should never happen on Solaris. The AC_FUNC_MALLOC autoconf
macro checks whether malloc(0) returns a valid pointer, which it does on
Solaris (and Linux). You could check the version of autoconf, maybe
upgrading it will help. Or there could be problems with the autoconf
input files for the project.

-Jerry

 
 Anil
 ___
 ug-bosug mailing list
 List-Unsubscribe: mailto:ug-bosug-unsubscribe at opensolaris.org
 List-Owner: mailto:ug-bosug-owner at opensolaris.org
 List-Archives: http://www.opensolaris.org/jive/forum.jspa?forumID=54
-- next part --
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3701 bytes
Desc: S/MIME Cryptographic Signature
URL: 
http://mail.opensolaris.org/pipermail/ug-bosug/attachments/20070810/c20fc2c6/attachment.bin


[ug-bosug] porting libntp .. AC_FUNC_MALLOC error

2007-08-09 Thread S h i v
On 8/9/07, Anil Gulecha anil.verve at gmail.com wrote:
 Hi all,

 I was trying to port libntp library that allows talking to
 Creative(and other) mp3 players.. the source consists of the libraries
 and a sample application.

 I had the initial -Wall errors that I corrected and the library has
 built fine. However, the sample app isnt building.

 bash-3.00$ pwd
 /tmp/libnjb-2.2.5
 bash-3.00$ ls src/.libs/
 base.o   ioutil.olibnjb.sonjbtime.oprotocol3.o
 byteorder.o  libnjb.alibnjb.so.5  playlist.o   songid.o
 datafile.o   libnjb.la   libnjb.so.5.1.0  procedure.o  unicode.o
 eax.olibnjb.lai  njb_error.o  protocol.o   usb_io.o
 bash-3.00$ cd sample/
 bash-3.00$ make
 /bin/bash ../libtool --tag=CC --mode=link /opt/SUNWspro/bin/cc
 -I../src -g  -L/usr/sfw/lib -o cursesplay  cursesplay.o
 ../src/libnjb.la -lcurses -lusb
 /opt/SUNWspro/bin/cc -I../src -g -o .libs/cursesplay cursesplay.o
 -L/usr/sfw/lib ../src/.libs/libnjb.so -lcurses -lusb -R/usr/local/lib
 Undefined   first referenced
  symbol in file
 rpl_malloc  ../src/.libs/libnjb.so
 ld: fatal: Symbol referencing errors. No output written to .libs/cursesplay
 make: *** [cursesplay] Error 1
 bash-3.00$


 Upon googling I found out about AC_FUNC_MALLOC macro in configure.ac
 that checks for correct calling of malloc, and malloc is replaced by
 rpl_malloc for incorrect calling.

 Workarounds are given at http://wiki.buici.com/wiki/Autoconf_and_RPL_MALLOC

 but these appear to be more hacky that a correct workaround. According
 to http://cygwin.com/ml/automake/2003-05/msg00043.html that error
 comes forward when malloc isn't correctly called.. and thus the
 correct thing to do in this situation is patch the source by clearing
 this error.

 My questions are:

 What is the ideal way to patch this error?
 What is the best way to patch this error for a spec file?
 I removed the -Wall flag from the Makefiles.. however this was said to
 be hacky, What is the correct way of going about correcting this
 error?


The AC_FUNC_MALLOC is to safeguard against libs that do unsafe memory
allocation.
If someone puts this check in the configure.ac, then one of the two
should be done
a) The author should also put the guard code that introduces
rpl_malloc OR remove the check if not relevant.
b) The person who has downloaded and is using the code should verify
if the compiler does a safe mem allocation and remove it. (if it
doesn't it is a bug against the compiler !)
I feel this check by configure script is useless and may be removed.

Regarding the other question about correct way to do, depending on you
want to use gcc or not do the following
1. If you use gcc, set CC=gcc before calling configure script in the
spec file so that Makefile generated just works.
2. If you use sunpro, then
a) Create a patch that patches the makefile after configure script is
run. This can never be submitted upstream and since it patches a
temporary file, it is kind of hacky. But it works just fine as a quick
solution.
b) Better way would be to introduce a test in configure to test if the
compiler is gcc, and in Makefile template (Makefile.am) you may use
the condition to set the CFLAGS depending on whether compiler is gcc
or not. This way the solution goes into the sources and can be
submitted to the original author. You wouldn't need to maintain the
patch whenever the original sources change.

regards
Shiv