1

I've already reported this directly to the X-SuperObject project, but I thought I may get more quality help on Stack Overflow.

Using Delphi XE8, I have issues using XSuperObject on iOS Simulator (7.1, 8.1, 8.2 and 8.3). So I started an empty Firemonkey app, started adding some things which were in my prior project (at this point I didn't know what the issue was). All worked fine up until I added the latest XSuperObject and XSuperJSON units to my app.

uses
  XSuperObject, XSuperJSON;

Upon running in the iOS simulator, I get an exception:

Project dyld_sim raised exception class EOSError with message 'System Error. Code: 2. No such file or directory.

I have no code, and have made no changes other than adding units (XSuperObject, XSuperJSON) and a few basic controls (Panel, Button, and Combo Box).

When I break, it takes me to:

System.SysUtils.RaiseLastOSError - last line raise Error;

...which is just the spot where the actual exception itself was raised, nothing of relevance.

So I opened the main project file and put a break point right on the first line Application.Initialize; but that break point is never reached. I also put breakpoints in the "initialization" of both XSuperObject and XSuperJSON and neither of them stop either.

Call Stack

Once I removed both units, everything worked again.

What's going wrong here and how do I fix it?

  • X-SuperObject Version: Pulled update from here just prior to reporting
  • Delphi XE8 Version 22.0.19027.8951 (No Updates)
  • IDE OS: Windows 7 SP1 (Version 6.1, Build 7601, 64bit)
  • Mac OS: OS-X 10.10.3
  • Target OS: iOS Simulator - iPad Air / iOS 8.2 (12D508)

NOTE: Above version details are just one specific example, but I cannot get it to work on any iOS device/version.

UPDATE: After debugging the system (the 115th unit initialization), I came to learn the point where the exception is raised. In System.RegularExpressionsCoreon line 680...

{$IFDEF DYNAMIC_LIB}
class constructor TPerlRegEx.Create;
begin
  if not LoadPCRELib then
    RaiseLastOSError; //<-- Exception raised here
end;
{$ENDIF DYNAMIC_LIB}

And inside of LoadPCRELib...

{$IFDEF DYNAMIC_LIB}
function LoadPCRELib: Boolean;

  function GetProcAddr(const ProcName: MarshaledAString): Pointer;
  begin
    dlerror;
    Result := dlsym(_PCRELib, ProcName);
  end;

  procedure SetCallback(const cbName: MarshaledAString; ProcPointer: Pointer);
  begin
    Pointer(GetProcAddr(cbName)^) := ProcPointer;
  end;

begin
  Result := True;
  if _PCRELib = 0 then
  begin
    Result := False;
    _PCRELib := HMODULE(dlopen(PCRELib, RTLD_LAZY)); //<-- Returns 0 (no handle)
    if _PCRELib <> 0 then
    begin
      // Setup the function pointers
      ...
      Result := True;
    end;
  end;
end;
{$ENDIF}

While running a project using only this unit, it runs just fine though.

So it seems to be unable to find /usr/lib/libpcre.dylib, but only if I'm using X-SuperObject.

I've updated all of my environment, including OS-X, XCode, iOS Simulator, and SDK links in Delphi IDE (Deleted all and recreated them). I've verified the SDK and iOS versions all match perfectly. But the problem still persists.

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • Can't you get a call stack? – David Heffernan May 30 '15 at 14:38
  • You need more info. Is it not possible to include debug info for startup code? For the desktop compiler you'd check "Use Debug DCUs". Is there an equivalent for the mobile compilers? – David Heffernan May 30 '15 at 14:48
  • The point is you want to know which function call lead to the OS error being raised. It's clearly in the process startup code. So you need debug info for that. I've no experience of any Delphi compiler other than the desktop compilers. – David Heffernan May 30 '15 at 14:52
  • Great. I should have been able to see that, it's clear now I look again. Which line of `System._StartExe` is calling `RaiseLastOSError`? – David Heffernan May 30 '15 at 15:25
  • Note that your failure is long before the code in the .dpr file runs. And presumably even before the units are initialized. It's worth pressing F7 and stepping into and then through startup to be familiar with how it flows. – David Heffernan May 30 '15 at 15:43
  • Found it (after over a hundred different unit initializations). In System.RegularExpressionsCore `class constructor TPerlRegEx.Create;` upon `LoadPCRELib`. – Jerry Dodge May 30 '15 at 15:52
  • Now try a project that just uses `System.RegularExpressions` and nothing else. – David Heffernan May 30 '15 at 15:58
  • @David Works fine. Updated question with further info. – Jerry Dodge May 30 '15 at 16:01
  • I've updated all my SDK's (actually deleted and recreated them) and the problem still persists on all iOS platforms. – Jerry Dodge May 30 '15 at 18:25
  • Try to remove the line `System.StartUpCopy,` from the top of your .dpr file. I had to remove it in XE8 to get rid of the same error. – Hans May 30 '15 at 18:40
  • @Hans Good suggestion, as I recall that helping one prior time. However, in this case, my test app doesn't even have that line in the first place. – Jerry Dodge May 30 '15 at 18:41
  • @JerryDodge Maybe I remembered wrong. Now that I see the answer about installing the Hotfix, that might actually be what solved it for me. – Hans May 31 '15 at 07:27
  • @Hans Actually I think I removed it already from the beginning, because another new app has it. – Jerry Dodge May 31 '15 at 08:38

1 Answers1

3

Please install the iOS 8 Simulator Hotfix, then it should work fine.

Sebastian Z
  • 4,520
  • 1
  • 15
  • 30