caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Ocaml and Samba function name collisions
       [not found] ` <20031124095952.GE25688@redhat.com>
@ 2003-11-25  0:31   ` Blair Zajac
  2003-11-25  7:38     ` Stefano Zacchiroli
  0 siblings, 1 reply; 7+ messages in thread
From: Blair Zajac @ 2003-11-25  0:31 UTC (permalink / raw)
  To: Caml Users Mailing List

Hello,

The synopsis of this message is to ask that the Ocaml source
code prepend a Ocaml specific string, "ml_", "caml_" or "ocaml_"
to all function names in Ocaml's source code to avoid name
collisions with other packages.  My case is made below :)

I'm using mod_caml and mod_smbauth in an Apache 1 process.
mod_smbauth is used to authenticate access to the web server
using our ActiveDirectory server.

http://www.tekrat.com/smbauth.php

When mod_caml.so is enabled in Apache httpd's conf file, it
core dumps with this stack backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1075767456 (LWP 3544)]
0x40b8a9cc in string_init (dest=0x40cb146c, src=0x1 <Address 0x1
out of bounds>) at lib/util_str.c:1142
1142      l = strlen(src);
(gdb) bt
#0  0x40b8a9cc in string_init (dest=0x40cb146c, src=0x1
<Address 0x1 out of bounds>) at lib/util_str.c:1142
#1  0x40b8ab21 in string_set (dest=0x1, src=0x0) at lib/util_str.c:1187
#2  0x40c34a4e in interprete () from
/opt/i386-linux/installed/apache-1.3.29-g/libexec/mod_caml.so
#3  0x40c265b1 in caml_main () from
/opt/i386-linux/installed/apache-1.3.29-g/libexec/mod_caml.so
#4  0x40c22ff4 in init () at mod_caml_c.c:80
#5  0x40c36975 in __do_global_ctors_aux () from
/opt/i386-linux/installed/apache-1.3.29-g/libexec/mod_caml.so
#6  0x40c20b95 in _init () from
/opt/i386-linux/installed/apache-1.3.29-g/libexec/mod_caml.so
...

Looking at the function names, both the Samba library and the
Ocaml source code have a function named string_set.  It's odd
though that the function name is binding to the Samba function
in mod_smbauth.so instead of the name in mod_caml.so, but then
I'm not an expert in shared library binding.

% nm mod_caml.so | grep string_set
00019846 T string_set
% nm mod_smbauth.so | grep string_set
00052afe T string_set
000552f9 T string_set_w

Now this may be a bug that can be worked around, but given
Ocaml's popularity in being linked with other packages, it
seems like a good idea to put all the Ocaml names into their
own space via a prepend.

I'd be happy to do some of this work by submitting patches to
the appropriate people/mailing list for review.  Let me know.

Best,
Blair

-- 
Blair Zajac <blair@orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25  0:31   ` [Caml-list] Ocaml and Samba function name collisions Blair Zajac
@ 2003-11-25  7:38     ` Stefano Zacchiroli
  2003-11-25  7:52       ` Nicolas Cannasse
  2003-11-25  9:21       ` Richard Jones
  0 siblings, 2 replies; 7+ messages in thread
From: Stefano Zacchiroli @ 2003-11-25  7:38 UTC (permalink / raw)
  To: Caml Users Mailing List

On Mon, Nov 24, 2003 at 04:31:24PM -0800, Blair Zajac wrote:
> The synopsis of this message is to ask that the Ocaml source
> code prepend a Ocaml specific string, "ml_", "caml_" or "ocaml_"
> to all function names in Ocaml's source code to avoid name
> collisions with other packages.  My case is made below :)

I will definitely sign this petition. I had a similar problem while
trying to write an ocaml binding to the graphviz library. Both the
libraries defined, IIRC, a color struct used in graphviz for node colors
and in ocaml by the GC :-(

Cheers.

-- 
^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$
^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$
^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$
^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25  7:38     ` Stefano Zacchiroli
@ 2003-11-25  7:52       ` Nicolas Cannasse
  2003-11-25 12:55         ` Samuel Mimram
  2003-11-25  9:21       ` Richard Jones
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Cannasse @ 2003-11-25  7:52 UTC (permalink / raw)
  To: Stefano Zacchiroli, Caml Users Mailing List

> > The synopsis of this message is to ask that the Ocaml source
> > code prepend a Ocaml specific string, "ml_", "caml_" or "ocaml_"
> > to all function names in Ocaml's source code to avoid name
> > collisions with other packages.  My case is made below :)
>
> I will definitely sign this petition. I had a similar problem while
> trying to write an ocaml binding to the graphviz library. Both the
> libraries defined, IIRC, a color struct used in graphviz for node colors
> and in ocaml by the GC :-(

This is not a primitive name problem, but a data structure one (when
including file).
It can be easily resolved by using a #define color caml_color (or the
working equivalent) before including the caml headers.
Other solution is to put the caml headers into a C++ namespace.
BTW I'm not signing this petition : having everything prefixed with caml_ is
way to heavy. But for theses string_get string_set primitives that's true
the naming is too much generic and proper to name collision. Only theses
kinds should be renamed.

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25  7:38     ` Stefano Zacchiroli
  2003-11-25  7:52       ` Nicolas Cannasse
@ 2003-11-25  9:21       ` Richard Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Jones @ 2003-11-25  9:21 UTC (permalink / raw)
  To: Caml Users Mailing List

On Tue, Nov 25, 2003 at 08:38:25AM +0100, Stefano Zacchiroli wrote:
> On Mon, Nov 24, 2003 at 04:31:24PM -0800, Blair Zajac wrote:
> > The synopsis of this message is to ask that the Ocaml source
> > code prepend a Ocaml specific string, "ml_", "caml_" or "ocaml_"
> > to all function names in Ocaml's source code to avoid name
> > collisions with other packages.  My case is made below :)
> 
> I will definitely sign this petition. I had a similar problem while
> trying to write an ocaml binding to the graphviz library. Both the
> libraries defined, IIRC, a color struct used in graphviz for node colors
> and in ocaml by the GC :-(

Ditto. Try linking caml with libperl some time. I did, and it's really
not pleasant. BOTH packages make claims on the whole namespace, and
there are conflicts.

Look at how tcl and tk use namespace some time for an example of how
to get this right.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles,
RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25  7:52       ` Nicolas Cannasse
@ 2003-11-25 12:55         ` Samuel Mimram
  2003-11-25 14:32           ` Nicolas Cannasse
  0 siblings, 1 reply; 7+ messages in thread
From: Samuel Mimram @ 2003-11-25 12:55 UTC (permalink / raw)
  To: Caml Users Mailing List

We've had recently exactly the same problem with libsmbclient (we even posted it here but no one seemed to have noticed it). The only solution we found yet was to modify the source code of libsmbclient to rename the colliding names (string_set and sys_open). But this is clearly not a good solution.

The #define you suggested does not seem to work and I think this is beacause they are not exported in the header files but are in the the .so and therefore visible in the global C namespace. And I'd prefer not to have to use C++ (I think I should be able to do it in C), so I did not try the namspace trick.

That's why, unless someone has a canonical solution to the problem, I think functions with such common names should have their names prefixed.


Samuel Mimram.


On Tue, 25 Nov 2003 16:52:22 +0900
"Nicolas Cannasse" <warplayer@free.fr> wrote:

> > > The synopsis of this message is to ask that the Ocaml source
> > > code prepend a Ocaml specific string, "ml_", "caml_" or "ocaml_"
> > > to all function names in Ocaml's source code to avoid name
> > > collisions with other packages.  My case is made below :)
> >
> > I will definitely sign this petition. I had a similar problem while
> > trying to write an ocaml binding to the graphviz library. Both the
> > libraries defined, IIRC, a color struct used in graphviz for node colors
> > and in ocaml by the GC :-(
> 
> This is not a primitive name problem, but a data structure one (when
> including file).
> It can be easily resolved by using a #define color caml_color (or the
> working equivalent) before including the caml headers.
> Other solution is to put the caml headers into a C++ namespace.
> BTW I'm not signing this petition : having everything prefixed with caml_ is
> way to heavy. But for theses string_get string_set primitives that's true
> the naming is too much generic and proper to name collision. Only theses
> kinds should be renamed.
> 
> Nicolas Cannasse
> 
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


-- 
Samuel Mimram

samuel.mimram@ens-lyon.fr

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25 12:55         ` Samuel Mimram
@ 2003-11-25 14:32           ` Nicolas Cannasse
  2003-11-26  7:17             ` Blair Zajac
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Cannasse @ 2003-11-25 14:32 UTC (permalink / raw)
  To: Samuel Mimram, Caml Users Mailing List

> The #define you suggested does not seem to work and
> I think this is beacause they are not exported in the header
> files but are in the the .so and therefore visible in the global
> C namespace. And I'd prefer not to have to use C++ (I think
> I should be able to do it in C), so I did not try the namspace trick.

This trick was an answer to Stephano problem about the struct color defined
by the camlheaders (if I understood correcly). I'm not sure there is a
workaround for the dl primitives name collisions which does not require the
modification of one of the two dlls.

Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Ocaml and Samba function name collisions
  2003-11-25 14:32           ` Nicolas Cannasse
@ 2003-11-26  7:17             ` Blair Zajac
  0 siblings, 0 replies; 7+ messages in thread
From: Blair Zajac @ 2003-11-26  7:17 UTC (permalink / raw)
  To: Nicolas Cannasse; +Cc: Samuel Mimram, Caml Users Mailing List

Nicolas Cannasse wrote:
> 
> > The #define you suggested does not seem to work and
> > I think this is beacause they are not exported in the header
> > files but are in the the .so and therefore visible in the global
> > C namespace. And I'd prefer not to have to use C++ (I think
> > I should be able to do it in C), so I did not try the namspace trick.
> 
> This trick was an answer to Stephano problem about the struct color defined
> by the camlheaders (if I understood correcly). I'm not sure there is a
> workaround for the dl primitives name collisions which does not require the
> modification of one of the two dlls.

I agree.  I don't think there's a workaround for this.

As getting patches and/or commit access to the Ocaml CVS tree is not
easy, I'm thinking of setting up a web page for patches to the official
Ocaml distrubtition.  I think this would be good for several reasons:

1) Anybody can submit then and they can be reviewed by the community.
   This would generate good quality patches.

2) The patches would be online in an easily accessible place when a
   Ocaml CVS committer wants to include them into the official
   distribution.  This could be done before a new Ocaml release,
   although patches should be applied to CVS as soon as possible
   to make the patching easier (less conflicts) and to test the code.

3) All patches would be in one location.

I've got two patches I would want in, the first for fixing this
function naming issue, the second free()ing some memory to avoid
a valgrind warning.

Best,
Blair

-- 
Blair Zajac <blair@orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-11-26  7:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3FC174F5.13617AC8@orcaware.com>
     [not found] ` <20031124095952.GE25688@redhat.com>
2003-11-25  0:31   ` [Caml-list] Ocaml and Samba function name collisions Blair Zajac
2003-11-25  7:38     ` Stefano Zacchiroli
2003-11-25  7:52       ` Nicolas Cannasse
2003-11-25 12:55         ` Samuel Mimram
2003-11-25 14:32           ` Nicolas Cannasse
2003-11-26  7:17             ` Blair Zajac
2003-11-25  9:21       ` Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).