MacOS Error code: -2707 Displayed at End of Some Scripts in BBEdit

I have an annoying problem that I don’t know how to debug. I suspect it’s a BBEdit issue, but it only affects my Applescripting. At the end of certain Applescript routines performed within BBEdit, usually just before the results are inserted back into an open document, I get a dialog box which displays “This operation couldn’t be completed, because an error occurred. (MacOS Error code: -2707)”

The results of the script are always contained in the clipboard, so I usually just dismiss the dialog box and paste the results.

This always happens only at the very end of the script. If I add more statements in the script before the end, they’ll execute properly but at termination the dialog box shows up.

The insertion into the open document isn’t the problem. Interim steps in the script which call for the same type of insertion in BBEdit work without error.

And some of these scripts are legacy scripts which worked fine in previous versions of BBEdit. At some upgrade point in the past, these started showing up.

Seen this before? Any ideas?

Thanks very much!

pipsqueak,

I quick look at MacErrors.h shows me the error

errOSAInternalTableOverflow = -2707, /* Signaled when a runtime internal data structure overflows*/

my feeling is that you may be trying to put to much into the clipboard but I don’t know this may very well be a problem with bbedit but I have no real way to see whats happening could you maybe post on of your scripts so that we can take a closer look ?

mm

Thanks, Mcgrailm,

It would be difficult to post a script because it uses a set of routines in a different file – which may be part of the problem. I couldn’t find the error, so it’s helpful to know that it’s a data structure overflow problem. I’ll need to poke around a bit more.

Best,

Sorry I could be more helpful… I hope it works out for you.

mm

Thanks. It was very helpful to find out what the error code meant. I always figured it was some kind of memory error. I don’t think it’s too much in the clipboard because it happens on rather small text snippets. It only seems to bite me on the scripts which call other scripts – perhaps it’s some kind of recursion.

But I do appreciate your research on the error code. I looked up the source you referenced, which looked like a header file – part of Carbon? A C file? Perl? Where do I get my hands on macerrors.h?

Best,

It came with xcode if you have xcode then you have the errors.h file. its a header file I think its objective C I don’t know for sure I use that file only to find out what errors are. and I am novice when it comes to xcode.

mm

Ah, never installed XCode. I’ll have to give it a look. Thanks!

Here’s where it is on my machine…
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h

Did you guys ever find a resolution for this error, I am getting the same thing using Photoshop with AppleScript.

"Could not save changes to this script because of a scripting system (OSA) error. -2707

Save changes? I’m not saving any changes in my AppleScript??

Also if I run the script within Script Editor I do not get the error. However, if I run the script as an app being called from a shell command then I get the -2707 error at the end of the script.

1 Like

“Me too”

I only try to save a four digit integer in a persistent property.

re: errOSAInternalTableOverflow
I realize that this is a freshly zombified thread, but there is precious little hard data around this topic and I’m looking to find the edge of the map.

Adding data points to this discussion.

I happen to have around 1000 unique handlers lying around that are very consistent in their structure. Each is 9 lines. Each has three nested tells and a single return statement that returns a UI element.

on handlerName()
    tell app
        tell app process
            tell reference within app process ( this line may vary in length / element count )
                return UIelement  ( this line may vary in length / element count )
            end
        end
    end
end

770 of these can be compiled and saved in a single .scpt file. After that, adding the following handler will result in an errOSAInternalTableOverflow.

on test()
	set x to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
end test

While I CAN save the script with the same test() handler with it’s list shortened to only 10 items.

This very large valid script is:
7044 total compiled lines.
261998 compiled characters. ( ~ 512 ^ 2 )
2.2 MB saved file size

Adding a hundred lines of commented out handlers has no effect on saving the script.
Duplicating the entire script into a block comment causes the script to fail to save with errOSAInternalTableOverflow.

I suppose I could test for character limits, word limits, line limits, defined term limits, etc. And sketch out some boundaries.