Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001323OCamlOCaml generalpublic2002-08-13 17:062002-08-19 10:52
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001323: Native-code "C" interface bug
DescriptionHi,

The attached code seems to exhibit a bug in native code compilation in
Objective CAML. I'm using:

  Linux 2.4.18, Pentium 3, ocaml versions 3.04, 3.05,
    gcc version 2.95.4 20011002 (Debian prerelease)
  Linux 2.4.18, StrongARM, ocaml version 3.04
    gcc version - don't know offhand, the one in Debian/ARM unstable

The attached program has been stripped down (a bit) to a subset which
still exhibits the bug.

What happens: with "make", "./sim", the program loads an ELF-(ish) file
into memory, then exits. With "make opt", "./sim.opt", the program
exits with a segfault after reading some of the file.

Under valgrind:

==1309== valgrind-1.0.0, a memory error detector for x86 GNU/Linux.
==1309== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==1309== Estimated CPU clock rate is 803 MHz
==1309== For more details, rerun with: -v
==1309==
Loading doptest to 0 (C)
Reading program section 0 from offset 568
Writing d8000000 to 10000000
Writing 4b3c0002 to 10000004
==1309== Invalid read of size 4
==1309== at 0x805BD9E: format_caml_exception (in /mnt/chunky/code/ocaml-bug/sim.opt)
==1309== by 0x805BF36: fatal_uncaught_exception (in /mnt/chunky/code/ocaml-bug/sim.opt)
==1309== by 0x805D8A3: caml_main (in /mnt/chunky/code/ocaml-bug/sim.opt)
==1309== by 0x8052729: main (in /mnt/chunky/code/ocaml-bug/sim.opt)
==1309== Address 0x4B3C0000 is not stack'd, malloc'd or free'd
Segmentation fault

If the function call "fread(&val, sizeof(int), 1, f)" is removed from
the file loadelf_c.c, the program seems to work. Likewise if the call
to callback3 is removed.

Thank you for your time, I hope this can be fixed.

Julian

----------------
‹ 'Y=íMoÜÖ‘þ@ ±ª)ÐSñ"Ë)¹Þ¥¸ÜÕÊ•´Fäͺv,[Få"M›bKqßJ´¸ä–äZ’£)jäPHäØC@þ¹è±@m€òrñ!ÉÌû ¹ôÊJKŽÑ7Ð.ùfæÍÌ›73oÈUä¹Ã ¶5Þ^ÐŽ
l»i/-.ÂÕ®/-ÚÅ«
œ–ã4­%Í®×—–?,ŸI9Œ“Ô? Ñ<ƒï(úK
Q¶ÿ7Ü]:ðúüuØuÛn5›‡í}ÑYÌö¿¾øz£éÀþÛÏß”§áÿ|ÿõN‡Ì´g¶=Oï\Y_ûÙ& j©mëëÝ_δ ƒ&Ý×ß^ët–#\Ï#µ»zgíƺ p‚‡2vãÖmÒæÈh”’šç±Ë¶~ífgýotI[×7.¿¹ LC:ŒâËFö%¥ì.ˆÜ>
ì~èú!ÞèzGLÔžgrýÚeÄmùÛn»(ÈÕõ›;oàÍ2"Ûðµïš@Ræ
¼AZÄh@²n]ݸùöòŒP7Ôu7–qu‰?ÔuXÀò ÜYp£ëŒcYŸ‰‡¤6 œÏ¾#öíÃw„ÓÈä1¥bõ'§?·úË3ç­a soöéˆÌ¯’KdþõŒèé°–NÇ$ó†p¯Ij7nä|
×ÁŒlÌ‘&›†»ì$E4ÌH¤ÁLÂÝgÊ™L’Å1oÜ<Dl=boÊ™%>.m‡•Ë¥ì@« ,>gñŸÅ³_Ã,(qE%GñÈŸtYq†zÁ¸OÉD?ô;à ­¿è¤þ ¯ÿyyÏYÇõ¿á,-Éúï´l<ÿ›6?Uý?8'cx5Iû~dí\Òs]@0- Ã஌i2ÉÌI¼~?Mð |n¹ÞîP"?éÁ„ÅPñ˜|V÷{,$
Ž=v*TI6ÆŽ%t‡E”ÛïǦ~_'ÄS‚£¸÷vܸB$;b®\[ïo»Á áôº;ý˜ÐÎÏQ·`T!£ Ü&Ã%‡:|¼aú+hÀ^ì§t/ŠûˆfkrcwØ0ró' —&Knð†4Œ˜&ŒrÙuíR7e\ðWTCÚÙCqý³Ã˜cT‚ä99µïµ0…U›QÔ,í†Í4öÃmÉ! RÊv(LÄ ?ã*™[‡m~r>!iDÎ÷‰Ñ1ß çª$_b¦烆A4¢¡‘Óçbn¤? Æ«îpû¦èê¸áOR‚³™tÐ9¡‰ !„îû©Q7WÈÂIwâh?¸! =:Jý(|x !1uûÆk¸áU8cïÑh`ä?`VI3‰¸ÿÌÉ©N°ho´Ž‡U’?h˜¢îL&zÄ$?›]ªH¦©H&æ$ST$E‡°K8)Š‰á·íâ¯í‚ñ… ¹Û'b?¡ö.æ×þo¸ƒ1èï¬èÓ÷èç”ÇÃ(Ž¶!î @·cd bh+¢Á ¡) ÙÖùU?÷˜¨¨viÔãd±“pKw?AµD­’Ín÷zo³{Û”VàÊîàÊî¬J^ŒŠä`.´›&ãº/t¡ýÞ+úB…#²¼sŒ))WYóDIwÙøº‚ÓEH±ù"¢@U1”¦zì-ÈU–Aû,ƒö™c˜?,q2‹0P¢ÑAÏÇL6Ê<0q’]Öá†Q)–?*™(N\?,?bò‘7ÓjÀQH-0; ´˜Rœ2V)ˆŒìQB?,.¡ÖMš,‚"8>?L¸G1MÇqˆµ°^ªNë› yÿÇŸ·†Áó×qDÿg·œVþþÇn±çÿFKõ'F…Ÿ¦?h8„]1u6¼, u==QhžÆá.dh¯Ýá(=å„Á»eP܉ÁR¸JØú7¨#^/p¢qj’5”Z·Ò)ó¯mÈÙ¤v‰Ï6Ie?7ãÐOMa Z0 ;ï=—…±Ì|V#`‰k!L‡ •N%?& |.¬8€Ó(G…Á€l
Ý]JšöO[ ð•&?›m‰Øh\lÚ&Y­É¥›4õVÂ.xLÀVD±Rl‚@´èäö?Ïaù1€£Þÿ5šyþ;Möþ¯å4TþŸ°lßÄLÐ)ìq¡\0e’Qà§Ø|@äymCîi„Ç8?À¤½ØßÞI{A´íCó‘1:6´E†dX“nØ'ö~c00 icŠBºÇsÚ0eBÖ-rÒWšdñò?
eÅ!†³ØªÔmG
cyö>5ñü—öðÇG4¹ ¦0Œ°Šõé>ê?º\?ÄZá¦ÞŽx_)ó_Ì7ÉžŸî°bÇœlååJ™(‚¨?Y
ZŠkeÂ9"êKA,`ƒ b-“ÁzÛ[¬S³xÃVh5ƒ}âb¾Ìúp±|!˜/z¥bfú¹Sï3üTËøu¬ÝÓ
ÀÕ=?¾žz¨²Ð‹î¡n²ÇEÆ?eß\xêýß1Gõu§^zÿ×Xª/ªúP¨ÿ:ÝOiB?–/ÞȲ(’?P {)4шñ›6™Ë_ÔÍ©T{¹ Ðÿá/kÇñøwdþ7ìü÷_g±Žù‚*ÿOiúDEÀΤ‡Ï}òí}L·ýª)¾_&7x_’µV챈µˆà[|[µ.Ζ¬°ä?[sýh”Ò$?ã?¦u?Æ›_ê6™(?aMC€¯È¸tä}ÑN|‰!ϱǠãˆüwØ3Ÿüÿ§‰ùßhÕUþŸü¾»~åÔ©SÙø´vî6ŽÐ÷Mø|$ðM?hg4C›ÑNiH¿xš¡gñë3ñ‘¤¿r&×ñH|Šôrú{RÈl?þuå "ÆO±2…ï;‚÷[B>ÚþY?~V\¿_äkx4…ïGݨ×2;…ïÇE¾×5í¿ŸùÎ >æRûp¾ ¥õ"߯¦¬·!e °AÀ¨$?Ùk%;ÐÖ¥î–f¥Ðüi{fÒ¬¾›ºšµ•$šG| ù’ƒ!^>=­­^ÿƒöðOw'Ï>|bLøø/šö®Ÿ¬j¯¯nhÖŠF®#þ–Àüù—>™}ò!âÞÜo5í XÞ¿/kgßÿ£¦Ý2Ã:¾€ëÎÌ>ÔN‘‡Z.ã•Oþ1Ë\|g?}×þîþ½p ®ü71õ€¯¯Âç͵Gß6$?\?’üe–C’”Æå:uµ4~§4.×Ø?—Æ-?ÿ^ÿ«¬?A„GqÐçGa¯Çß)öüp4N{[)-ã0000875:0000007¦c@bÓ§ñŸ?xƒ?|x¬æüÑ8Í„¤Oýw Æ-ÑxLý¢î‡÷—WŸÛ¥q»4î–Æ
(P @?
(P @?
(P @?
(P @?
(P `:|‰Š]MP----------------
----------------
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0001031)
administrator (administrator)
2002-08-19 09:56

> The attached code seems to exhibit a bug in native code compilation in
> Objective CAML.

Indeed: wrong inline code was generated for bigarray assignments. More
precisely, the generated code forgot to put "()" as the result value
of a.{i} <- v, thus causing the callback mechanism to fail when
testing the return value for uncaught exceptions.

This will be fixed in release 3.06. In the meantime, you can work
around the problem by explicitly returning (), as follows:

let writeWord state address value =
  let (chunkno, index) = splitaddress address in
  match state.memory.(chunkno) with
    State.ChunkEmpty ->
      let array = newchunk () in
        state.memory.(chunkno) <- State.ChunkFull(array);
  (* Printf.printf "Writing %lx at %d:%d\n" value chunkno index;*)
        array.{index} <- value; () (* <============ *)
  | State.ChunkFull(array) ->
(* Printf.printf "Writing %lx at %d:%d\n" value chunkno index;*)
      array.{index} <- value; () (* <============ *)
  | State.ChunkIO(r, w) -> w index value

Cheers,

- Xavier Leroy

(0001032)
administrator (administrator)
2002-08-19 10:52

Fixed 2002-08-19 by XL

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker