<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Am 12.07.2010 um 13:24 schrieb Michael Van Canneyt:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br>Basically, any heap memory access and standard pascal I/O are forbidden in<br>threads started outside FPC, because the necessary thread structures are not<br>initialized correctly.</blockquote><div><br class="webkit-block-placeholder"></div><div>Is my assumption correct that this means I cannot use much of FPC then? As far as I can see, calling an object seems to be possible without any crash (aren't these on the heap too ?).</div><div><br class="webkit-block-placeholder"></div><div>Due to these limitations, I think the best then would be to switch from the C callback thread into the FPC thread - how would that be (safely) possible?</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><br><blockquote type="cite"><br><br>Michael.<br><br>On Mon, 12 Jul 2010, Alexander Grau wrote:<br><br><blockquote type="cite">Hello,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">While using an external C framework (Mac OS X, discrecording OS framework, FPC 2.4), I noticed that my FPC console app crashes when I use writeln's in both C threads (callbacks).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Example: Two FPC functions that are called from an external C library (c_callback1 and c_callback2) - callback2 is called within callback1 in another C thread (other than the FPC main thread).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">// called from external C framework within the FPC main thread<br></blockquote><blockquote type="cite">c_callback1; cdecl;<br></blockquote><blockquote type="cite">begin<br></blockquote><blockquote type="cite">writeln('callback1begin');<br></blockquote><blockquote type="cite">// c_ callback2 is called here from another C thread<br></blockquote><blockquote type="cite">writeln('callback1end'); <== my FPC console app crashes here ( "EInOutError - Disk Full")<br></blockquote><blockquote type="cite">end;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">// called from external C framework in another C thread<br></blockquote><blockquote type="cite">c_callback2; cdecl;<br></blockquote><blockquote type="cite">begin<br></blockquote><blockquote type="cite">writeln('callback2begin');<br></blockquote><blockquote type="cite">writeln('callback2end');<br></blockquote><blockquote type="cite">end;<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">An unhandled exception occurred at $000669E3 :<br></blockquote><blockquote type="cite">EInOutError : Disk Full<br></blockquote><blockquote type="cite">$000669E3 CALLBACK1, line xxx<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Question: Why isn't it safe to call writeln's in non-FPC threads? Are there any other FPC runtime functions I should not call within non-FPC threads?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I'm going to make an FPC wiki page ('Threading Pitfalls') that will discuss these and other issues related to threading and I welcome all explanations on this so I can better understand this problem! :-)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks,<br></blockquote><blockquote type="cite">Alexander<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote>_______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Best regards / Mit freundlichen Grüßen/<font class="Apple-style-span" face="Hiragino Kaku Gothic Pro"><span class="Apple-style-span" style="font-family: Hiragino Kaku Gothic Pro; ">順致最崇高的敬意</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Alexander Grau</span></span></span></span></span></span></span></span></font><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "> </span></span></span></span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><br class="khtml-block-placeholder"></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Grau GbR</span></span></span></span></span></span></span></span></font><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "> </span></span></span></span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Hardware & Software Solutions</span></span></span></span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Eschenweg 12</span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">32609 Huellhorst</span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Germany</span></span></span></span></span><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "> </span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" color="#001FD4"><br style="color: rgb(0, 31, 212); "></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" color="#001FD4"><a href="http://www.grauonline.de/"><span class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; ">www.grauonline.de</span></span></span></span></span></a></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Tel</span></span></span></span></span></span><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">: +49 (0) 5741 2301259</span></span></span></span></span></span></span></span></font><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "> </span></span></span></span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">Fax: +49 (0) 5741 235530 </span></span></span></span></span></span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">E</span></span></span></span></span></font><font class="Apple-style-span" color="#001FD4"><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); "><span class="Apple-style-span" style="color: rgb(0, 31, 212); ">-Mail: <a href="mailto:info@grauonline.de">info@grauonline.de</a></span></span></span></span></span></font></div><br class="Apple-interchange-newline"></span></span></span></span></span></span></span></div></span> </div><br></body></html>